#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*/ puts(char *);
int sleep(int);
int /*<<< orphan*/ sprintf(char *, char *, long);
void *tf(void *arg) {
  int n = (int)(long int)arg;
  char number[160];
  int unslept = 10;
  sprintf(number, "tf(%ld): begin", (long)arg);
  puts(number);
  while (unslept > 0)
    unslept = sleep(unslept);
  sprintf(number, "tf(%ld): end", (long)arg);
  puts(number);
  return NULL;
}


x86 assembly (clang, -O0):
<tf>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %eax,-0xc(%rbp)
movl   $0xa,-0xb4(%rbp)
lea    -0xb0(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe9e(%rip),%rsi
call   1040 <sprintf@plt>
lea    -0xb0(%rbp),%rdi
call   1030 <puts@plt>
cmpl   $0x0,-0xb4(%rbp)
jle    1196 <tf+0x66>
mov    -0xb4(%rbp),%edi
call   1050 <sleep@plt>
mov    %eax,-0xb4(%rbp)
jmp    1173 <tf+0x43>
lea    -0xb0(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe67(%rip),%rsi
call   1040 <sprintf@plt>
lea    -0xb0(%rbp),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tf>:
push   %r14
push   %rbx
sub    $0xa8,%rsp
mov    %rdi,%rbx
lea    0xebc(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
mov    %rbx,%rdx
call   1040 <sprintf@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    $0xa,%eax
nop
mov    %eax,%edi
call   1050 <sleep@plt>
test   %eax,%eax
jg     1160 <tf+0x30>
lea    0xe9d(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
mov    %rbx,%rdx
call   1040 <sprintf@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0xa8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [15 x i8] c"tf(%ld): begin\00"
@.str.1 = [13 x i8] c"tf(%ld): end\00"
define i8* @tf(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca [160 x i8]
%5 = alloca i32
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = ptrtoint i8* %6 to i64
%8 = trunc i64 %7 to i32
store i32 %8, i32* %3
store i32 10, i32* %5
%9 = getelementptr inbounds [160 x i8], [160 x i8]* %4, i64 0, i64 0
%10 = load i8*, i8** %2
%11 = ptrtoint i8* %10 to i64
%12 = call i32 @sprintf(i8* %9, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i64 %11)
%13 = getelementptr inbounds [160 x i8], [160 x i8]* %4, i64 0, i64 0
%14 = call i32 @puts(i8* %13)
br label %15
15: ; preds = %18, %1
%16 = load i32, i32* %5
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = load i32, i32* %5
%20 = call i32 @sleep(i32 %19)
store i32 %20, i32* %5
br label %15
21: ; preds = %15
%22 = getelementptr inbounds [160 x i8], [160 x i8]* %4, i64 0, i64 0
%23 = load i8*, i8** %2
%24 = ptrtoint i8* %23 to i64
%25 = call i32 @sprintf(i8* %22, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i64 %24)
%26 = getelementptr inbounds [160 x i8], [160 x i8]* %4, i64 0, i64 0
%27 = call i32 @puts(i8* %26)
ret i8* null
}

LLVM IR (-O2):
@.str = [15 x i8] c"tf(%ld): begin\00"
@.str.1 = [13 x i8] c"tf(%ld): end\00"
define noalias i8* @tf(i8* %0) {
%2 = alloca [160 x i8]
%3 = ptrtoint i8* %0 to i64
%4 = getelementptr inbounds [160 x i8], [160 x i8]* %2, i64 0, i64 0
%5 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i64 %3)
%6 = call i32 @puts(i8* %4)
br label %7
7: ; preds = %1, %7
%8 = phi i32 [ 10, %1 ], [ %9, %7 ]
%9 = tail call i32 @sleep(i32 %8)
%10 = icmp sgt i32 %9, 0
br i1 %10, label %7, label %11
11: ; preds = %7
%12 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i64 %3)
%13 = call i32 @puts(i8* %4)
ret i8* null
}