#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 */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sleep(int);
void *Thread_C2(void *arg) {
  int *number = 0;
  number = (int *)arg;
  while (1) {
    if (*number) {
      printf("value = %d\n", *number);
      *number = 0;
    } else {
      printf("I am alive\n");
    }
    sleep(1);
  }
}


x86 assembly (clang, -O0):
<Thread_C2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpl   $0x0,(%rax)
je     116c <Thread_C2+0x4c>
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
jmp    117a <Thread_C2+0x5a>
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <sleep@plt>
jmp    113c <Thread_C2+0x1c>

x86 assembly (clang, -O2):
<Thread_C2>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
lea    0xecd(%rip),%r14
lea    0xeba(%rip),%r15
jmp    1162 <Thread_C2+0x32>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    (%rbx),%esi
test   %esi,%esi
je     1150 <Thread_C2+0x20>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movl   $0x0,(%rbx)
jmp    1158 <Thread_C2+0x28>

LLVM IR (-O0):
@.str = [12 x i8] c"value = %d\0A\00"
@.str.1 = [12 x i8] c"I am alive\0A\00"
define i8* @Thread_C2(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
store i8* %0, i8** %2
store i32* null, i32** %3
%4 = load i8*, i8** %2
%5 = bitcast i8* %4 to i32*
store i32* %5, i32** %3
br label %6
6: ; preds = %1, %17
%7 = load i32*, i32** %3
%8 = load i32, i32* %7
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %6
%11 = load i32*, i32** %3
%12 = load i32, i32* %11
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = load i32*, i32** %3
store i32 0, i32* %14
br label %17
15: ; preds = %6
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %17
17: ; preds = %15, %10
%18 = call i32 @sleep(i32 1)
br label %6
}

LLVM IR (-O2):
@.str = [12 x i8] c"value = %d\0A\00"
@str = [11 x i8] c"I am alive\00"
define noalias i8* @Thread_C2(i8* nocapture %0) {
%2 = bitcast i8* %0 to i32*
br label %3
3: ; preds = %10, %1
%4 = load i32, i32* %2
%5 = icmp eq i32 %4, 0
br i1 %5, label %8, label %6
6: ; preds = %3
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %4)
store i32 0, i32* %2
br label %10
8: ; preds = %3
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
br label %10
10: ; preds = %8, %6
%11 = tail call i32 @sleep(i32 1)
br label %3
}