#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
struct sio_timer {
  int dummy;
};
struct sio_dgram {
  int dummy;
};
struct sio {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int sio_dgram_write(struct sio *, struct sio_dgram *, char *, int, char *, int);
int /*<<< orphan*/ sio_start_timer(struct sio *, struct sio_timer *, int,
                                   void (*)(struct sio *, struct sio_timer *,
                                            void *),
                                   struct sio_dgram *);
void on_timer(struct sio *sio, struct sio_timer *timer, void *arg) {
  struct sio_dgram *sdgram = arg;
  if (sio_dgram_write(sio, sdgram, "127.0.0.1", 8990, "ping", 4) == -1) {
    printf("sio_dgram_write=-1\n");
  }
  sio_start_timer(sio, timer, 1000, on_timer, sdgram);
}


x86 assembly (clang, -O0):
<on_timer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
lea    0xea5(%rip),%rdx
mov    $0x231e,%ecx
lea    0xea3(%rip),%r8
mov    $0x4,%r9d
call   1040 <sio_dgram_write@plt>
cmp    $0xffffffff,%eax
jne    1187 <on_timer+0x57>
lea    0xe8d(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%r8
mov    $0x3e8,%edx
mov    0x2e51(%rip),%rcx
call   1050 <sio_start_timer@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<on_timer>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xebb(%rip),%rdx
lea    0xebe(%rip),%r8
mov    %r15,%rsi
mov    $0x231e,%ecx
mov    $0x4,%r9d
call   1040 <sio_dgram_write@plt>
cmp    $0xffffffff,%eax
jne    1170 <on_timer+0x40>
lea    0xea4(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e79(%rip),%rcx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x3e8,%edx
mov    %r15,%r8
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <sio_start_timer@plt>

LLVM IR (-O0):
%struct.sio = type { i32 }
%struct.sio_timer = type { i32 }
%struct.sio_dgram = type { i32 }
@.str = [10 x i8] c"127.0.0.1\00"
@.str.1 = [5 x i8] c"ping\00"
@.str.2 = [20 x i8] c"sio_dgram_write=-1\0A\00"
define void @on_timer(%struct.sio* %0, %struct.sio_timer* %1, i8* %2) {
%4 = alloca %struct.sio*
%5 = alloca %struct.sio_timer*
%6 = alloca i8*
%7 = alloca %struct.sio_dgram*
store %struct.sio* %0, %struct.sio** %4
store %struct.sio_timer* %1, %struct.sio_timer** %5
store i8* %2, i8** %6
%8 = load i8*, i8** %6
%9 = bitcast i8* %8 to %struct.sio_dgram*
store %struct.sio_dgram* %9, %struct.sio_dgram** %7
%10 = load %struct.sio*, %struct.sio** %4
%11 = load %struct.sio_dgram*, %struct.sio_dgram** %7
%12 = call i32 @sio_dgram_write(%struct.sio* %10, %struct.sio_dgram* %11, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 8990, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %16
14: ; preds = %3
%15 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %16
16: ; preds = %14, %3
%17 = load %struct.sio*, %struct.sio** %4
%18 = load %struct.sio_timer*, %struct.sio_timer** %5
%19 = load %struct.sio_dgram*, %struct.sio_dgram** %7
%20 = call i32 @sio_start_timer(%struct.sio* %17, %struct.sio_timer* %18, i32 1000, void (%struct.sio*, %struct.sio_timer*, i8*)* @on_timer, %struct.sio_dgram* %19)
ret void
}

LLVM IR (-O2):
%struct.sio = type { i32 }
%struct.sio_timer = type { i32 }
%struct.sio_dgram = type { i32 }
@.str = [10 x i8] c"127.0.0.1\00"
@.str.1 = [5 x i8] c"ping\00"
@str = [19 x i8] c"sio_dgram_write=-1\00"
define void @on_timer(%struct.sio* %0, %struct.sio_timer* %1, i8* %2) {
%4 = bitcast i8* %2 to %struct.sio_dgram*
%5 = tail call i32 @sio_dgram_write(%struct.sio* %0, %struct.sio_dgram* %4, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 8990, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
br label %9
9: ; preds = %7, %3
%10 = tail call i32 @sio_start_timer(%struct.sio* %0, %struct.sio_timer* %1, i32 1000, void (%struct.sio*, %struct.sio_timer*, i8*)* @on_timer, %struct.sio_dgram* %4)
ret void
}