#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 f_2(char *, int);
int /*<<< orphan*/ printf(char *, char *, ...);
void f_1(char *name, int x) {
  ;
  while (x > 0) {
    int f_2_ret = f_2(name, x);
    printf("%s f_1: x=%d f_2_ret=%d\n", name, x, f_2_ret);
    x--;
  }
  printf("%s f_1: DONE\n", name);
}


x86 assembly (clang, -O0):
<f_1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    116e <f_1+0x4e>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <f_2@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    112f <f_1+0xf>
mov    -0x8(%rbp),%rsi
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f_1>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
test   %esi,%esi
jle    1165 <f_1+0x45>
mov    %esi,%ebx
lea    0xecb(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <f_2@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
lea    -0x1(%rbx),%eax
cmp    $0x1,%ebx
mov    %eax,%ebx
ja     1140 <f_1+0x20>
lea    0xead(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [25 x i8] c"%s f_1: x=%d f_2_ret=%d\0A\00"
@.str.1 = [14 x i8] c"%s f_1: DONE\0A\00"
define void @f_1(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
br label %6
6: ; preds = %9, %2
%7 = load i32, i32* %4
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %19
9: ; preds = %6
%10 = load i8*, i8** %3
%11 = load i32, i32* %4
%12 = call i32 @f_2(i8* %10, i32 %11)
store i32 %12, i32* %5
%13 = load i8*, i8** %3
%14 = load i32, i32* %4
%15 = load i32, i32* %5
%16 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %13, i32 %14, i32 %15)
%17 = load i32, i32* %4
%18 = add nsw i32 %17, -1
store i32 %18, i32* %4
br label %6
19: ; preds = %6
%20 = load i8*, i8** %3
%21 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %20)
ret void
}

LLVM IR (-O2):
@.str = [25 x i8] c"%s f_1: x=%d f_2_ret=%d\0A\00"
@.str.1 = [14 x i8] c"%s f_1: DONE\0A\00"
define void @f_1(i8* %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %10
4: ; preds = %2, %4
%5 = phi i32 [ %8, %4 ], [ %1, %2 ]
%6 = tail call i32 @f_2(i8* %0, i32 %5)
%7 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %5, i32 %6)
%8 = add nsw i32 %5, -1
%9 = icmp ugt i32 %5, 1
br i1 %9, label %4, label %10
10: ; preds = %4, %2
%11 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %0)
ret void
}