#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 netsim {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, long);
int /*<<< orphan*/ netsim_clock_update(struct netsim *, long);
int netsim_sleep(int);
long netsim_timestamp();
int /*<<< orphan*/ stderr;
void *netsim_worker_proc(void *para) {
  struct netsim *sim = para;
  do {
    fprintf(stderr, "sim = %p\n", sim);
  } while (0);
  int r;
  for (;;) {
    long ts = netsim_timestamp();
    do {
      fprintf(stderr, "ts=%ld\n", ts);
    } while (0);
    netsim_clock_update(sim, ts);
    r = netsim_sleep(100);
  }
  return NULL;
}


x86 assembly (clang, -O0):
<netsim_worker_proc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    0x2e85(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe98(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1172 <netsim_worker_proc+0x32>
mov    $0x0,%al
call   1030 <netsim_timestamp@plt>
mov    %rax,-0x20(%rbp)
mov    0x2e5c(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xe79(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <netsim_clock_update@plt>
mov    $0x64,%edi
call   1060 <netsim_sleep@plt>
mov    %eax,-0x14(%rbp)
jmp    1172 <netsim_worker_proc+0x32>

x86 assembly (clang, -O2):
<netsim_worker_proc>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r15
mov    0x2e8e(%rip),%r12
mov    (%r12),%edi
lea    0xea3(%rip),%rsi
mov    %r15,%rdx
call   1040 <fprintf@plt>
lea    0xe9e(%rip),%r14
nopl   0x0(%rax)
xor    %eax,%eax
call   1030 <netsim_timestamp@plt>
mov    %rax,%rbx
mov    (%r12),%edi
mov    %r14,%rsi
mov    %rax,%rdx
call   1040 <fprintf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <netsim_clock_update@plt>
mov    $0x64,%edi
call   1060 <netsim_sleep@plt>
jmp    1170 <netsim_worker_proc+0x30>

LLVM IR (-O0):
%struct.netsim = type { i32 }
@stderr = global i32 0
@.str = [10 x i8] c"sim = %p\0A\00"
@.str.1 = [8 x i8] c"ts=%ld\0A\00"
define i8* @netsim_worker_proc(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.netsim*
%4 = alloca i32
%5 = alloca i64
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = bitcast i8* %6 to %struct.netsim*
store %struct.netsim* %7, %struct.netsim** %3
br label %8
8: ; preds = %1
%9 = load i32, i32* @stderr
%10 = load %struct.netsim*, %struct.netsim** %3
%11 = ptrtoint %struct.netsim* %10 to i64
%12 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i64 %11)
br label %13
13: ; preds = %8
br label %14
14: ; preds = %20, %13
%15 = call i64 (...) @netsim_timestamp()
store i64 %15, i64* %5
br label %16
16: ; preds = %14
%17 = load i32, i32* @stderr
%18 = load i64, i64* %5
%19 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i64 %18)
br label %20
20: ; preds = %16
%21 = load %struct.netsim*, %struct.netsim** %3
%22 = load i64, i64* %5
%23 = call i32 @netsim_clock_update(%struct.netsim* %21, i64 %22)
%24 = call i32 @netsim_sleep(i32 100)
store i32 %24, i32* %4
br label %14
}

LLVM IR (-O2):
%struct.netsim = type { i32 }
@stderr = global i32 0
@.str = [10 x i8] c"sim = %p\0A\00"
@.str.1 = [8 x i8] c"ts=%ld\0A\00"
define noalias i8* @netsim_worker_proc(i8* %0) {
%2 = bitcast i8* %0 to %struct.netsim*
%3 = load i32, i32* @stderr
%4 = ptrtoint i8* %0 to i64
%5 = tail call i32 @fprintf(i32 %3, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i64 %4)
br label %6
6: ; preds = %6, %1
%7 = tail call i64 (...) @netsim_timestamp()
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i64 %7)
%10 = tail call i32 @netsim_clock_update(%struct.netsim* %2, i64 %7)
%11 = tail call i32 @netsim_sleep(i32 100)
br label %6
}