#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 EXIT_SUCCESS;
int /*<<< orphan*/ close(int);
int creat(char const *, int);
int /*<<< orphan*/ fill_testfile(int, int);
int create_testfile(const char *testfile_name, int testfile_size) {
  int testfile_descriptor;
  testfile_descriptor = creat(testfile_name, 0666);
  if (testfile_size > 0)
    fill_testfile(testfile_descriptor, testfile_size);
  if (testfile_descriptor < 0)
    return (-1);
  close(testfile_descriptor);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<create_testfile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x1b6,%esi
call   1050 <creat@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    1165 <create_testfile+0x35>
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1040 <fill_testfile@plt>
cmpl   $0x0,-0x18(%rbp)
jge    117b <create_testfile+0x4b>
movl   $0xffffffff,-0x4(%rbp)
jmp    118f <create_testfile+0x5f>
mov    -0x18(%rbp),%edi
call   1030 <close@plt>
mov    0x2e56(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_testfile>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    $0x1b6,%esi
call   1050 <creat@plt>
mov    %eax,%ebx
test   %ebp,%ebp
jle    114e <create_testfile+0x1e>
mov    %ebx,%edi
mov    %ebp,%esi
call   1040 <fill_testfile@plt>
test   %ebx,%ebx
js     1164 <create_testfile+0x34>
mov    %ebx,%edi
call   1030 <close@plt>
mov    0x2e80(%rip),%rax
mov    (%rax),%eax
jmp    1169 <create_testfile+0x39>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@EXIT_SUCCESS = global i32 0
define i32 @create_testfile(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%7 = load i8*, i8** %4
%8 = call i32 @creat(i8* %7, i32 438)
store i32 %8, i32* %6
%9 = load i32, i32* %5
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i32, i32* %6
%13 = load i32, i32* %5
%14 = call i32 @fill_testfile(i32 %12, i32 %13)
br label %15
15: ; preds = %11, %2
%16 = load i32, i32* %6
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %15
store i32 -1, i32* %3
br label %23
19: ; preds = %15
%20 = load i32, i32* %6
%21 = call i32 @close(i32 %20)
%22 = load i32, i32* @EXIT_SUCCESS
store i32 %22, i32* %3
br label %23
23: ; preds = %19, %18
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
@EXIT_SUCCESS = global i32 0
define i32 @create_testfile(i8* %0, i32 %1) {
%3 = tail call i32 @creat(i8* %0, i32 438)
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @fill_testfile(i32 %3, i32 %1)
br label %7
7: ; preds = %5, %2
%8 = icmp slt i32 %3, 0
br i1 %8, label %12, label %9
9: ; preds = %7
%10 = tail call i32 @close(i32 %3)
%11 = load i32, i32* @EXIT_SUCCESS
br label %12
12: ; preds = %7, %9
%13 = phi i32 [ %11, %9 ], [ -1, %7 ]
ret i32 %13
}