#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*/ _IONBF;
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ setvbuf(int /*<<< orphan*/, int /*<<< orphan*/ *,
                           int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ test_rename_before_close(char *);
int main(int argc, char *argv[]) {
  setvbuf(stdout, NULL, _IONBF, 0);
  if (argc < 2) {
    printf("Usage: %s <file>", argv[0]);
    return 1;
  }
  test_rename_before_close(argv[1]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e8b(%rip),%rax
mov    (%rax),%edi
mov    0x2e92(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
xor    %ecx,%ecx
call   1040 <setvbuf@plt>
cmpl   $0x2,-0x8(%rbp)
jge    118c <main+0x5c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe85(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11a0 <main+0x70>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <test_rename_before_close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %edi,%ebp
mov    0x2e98(%rip),%rax
mov    (%rax),%edi
mov    0x2e9f(%rip),%rax
mov    (%rax),%edx
xor    %ebx,%ebx
xor    %esi,%esi
xor    %ecx,%ecx
call   1040 <setvbuf@plt>
cmp    $0x1,%ebp
jg     1171 <main+0x41>
mov    (%r14),%rsi
lea    0xe9b(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%ebx
jmp    117a <main+0x4a>
mov    0x8(%r14),%rdi
call   1050 <test_rename_before_close@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stdout = global i32 0
@_IONBF = global i32 0
@.str = [17 x i8] c"Usage: %s <file>\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* @stdout
%7 = load i32, i32* @_IONBF
%8 = call i32 @setvbuf(i32 %6, i32* null, i32 %7, i32 0)
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %14)
store i32 1, i32* %3
br label %21
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32 @test_rename_before_close(i8* %19)
store i32 0, i32* %3
br label %21
21: ; preds = %16, %11
%22 = load i32, i32* %3
ret i32 %22
}

LLVM IR (-O2):
@stdout = global i32 0
@_IONBF = global i32 0
@.str = [17 x i8] c"Usage: %s <file>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = load i32, i32* @stdout
%4 = load i32, i32* @_IONBF
%5 = tail call i32 @setvbuf(i32 %3, i32* null, i32 %4, i32 0)
%6 = icmp slt i32 %0, 2
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = load i8*, i8** %1
%9 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %8)
br label %14
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32 @test_rename_before_close(i8* %12)
br label %14
14: ; preds = %10, %7
%15 = phi i32 [ 1, %7 ], [ 0, %10 ]
ret i32 %15
}