#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ L_tmpnam;
int /*<<< orphan*/ check_int(int, int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ range(char *);
int /*<<< orphan*/ tmpnam(char *);
int main() {
  {
    char tmpFileName[L_tmpnam + 1];
    tmpnam(tmpFileName);
    FILE *fp = fopen(tmpFileName, "w");
    fputs("1231\n", fp);
    fputs("1\n", fp);
    fputs("441\n", fp);
    check_int(0, fclose(fp));
    check_int(1230, range(tmpFileName));
  }
  {
    char tmpFileName[L_tmpnam + 1];
    tmpnam(tmpFileName);
    FILE *fp = fopen(tmpFileName, "w");
    check_int(0, fclose(fp));
    check_int(1, range(tmpFileName));
  }
  {
    char tmpFileName[L_tmpnam + 1];
    tmpnam(tmpFileName);
    FILE *fp = fopen(tmpFileName, "w");
    fputs("1231\n", fp);
    fputs("\n", fp);
    fputs("22\n", fp);
    check_int(0, fclose(fp));
    check_int(-1, range(tmpFileName));
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    0x2e6e(%rip),%rax
mov    %rax,-0x58(%rbp)
mov    (%rax),%eax
add    $0x1,%eax
mov    %rsp,%rcx
mov    %rcx,-0x8(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x78(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x10(%rbp)
call   1080 <tmpnam@plt>
mov    -0x78(%rbp),%rdi
lea    0xe52(%rip),%rsi
mov    %rsi,-0x70(%rbp)
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe3c(%rip),%rdi
call   1050 <fputs@plt>
mov    -0x18(%rbp),%rsi
lea    0xe2f(%rip),%rdi
call   1050 <fputs@plt>
mov    -0x18(%rbp),%rsi
lea    0xe22(%rip),%rdi
call   1050 <fputs@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    %eax,%esi
xor    %edi,%edi
mov    %edi,-0x64(%rbp)
call   1040 <check_int@plt>
mov    -0x78(%rbp),%rdi
call   1060 <range@plt>
mov    %eax,%esi
mov    $0x4ce,%edi
call   1040 <check_int@plt>
mov    -0x58(%rbp),%rax
mov    -0x8(%rbp),%rcx
mov    %rcx,%rsp
mov    (%rax),%eax
add    $0x1,%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x60(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x28(%rbp)
call   1080 <tmpnam@plt>
mov    -0x70(%rbp),%rsi
mov    -0x60(%rbp),%rdi
call   1070 <fopen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x64(%rbp),%edi
mov    %eax,%esi
call   1040 <check_int@plt>
mov    -0x60(%rbp),%rdi
call   1060 <range@plt>
mov    %eax,%esi
mov    $0x1,%edi
call   1040 <check_int@plt>
mov    -0x58(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %rcx,%rsp
mov    (%rax),%eax
add    $0x1,%eax
mov    %rsp,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x50(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x40(%rbp)
call   1080 <tmpnam@plt>
mov    -0x50(%rbp),%rdi
lea    0xd37(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rsi
lea    0xd25(%rip),%rdi
call   1050 <fputs@plt>
mov    -0x48(%rbp),%rsi
lea    0xd19(%rip),%rdi
call   1050 <fputs@plt>
mov    -0x48(%rbp),%rsi
lea    0xd10(%rip),%rdi
call   1050 <fputs@plt>
mov    -0x48(%rbp),%rdi
call   1030 <fclose@plt>
mov    %eax,%esi
xor    %edi,%edi
call   1040 <check_int@plt>
mov    -0x50(%rbp),%rdi
call   1060 <range@plt>
mov    %eax,%esi
mov    $0xffffffff,%edi
call   1040 <check_int@plt>
mov    -0x38(%rbp),%rax
mov    %rax,%rsp
xor    %eax,%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsp,%r14
mov    0x2e58(%rip),%r13
mov    0x0(%r13),%eax
add    $0x1,%eax
mov    %rsp,%r12
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
mov    %r12,%rdi
call   1090 <tmpnam@plt>
lea    0xe51(%rip),%r15
mov    %r12,%rdi
mov    %r15,%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
lea    0xe3e(%rip),%rdi
mov    $0x5,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1080 <fwrite@plt>
lea    0xe28(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1080 <fwrite@plt>
lea    0xe12(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1080 <fwrite@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %edi,%edi
mov    %eax,%esi
call   1040 <check_int@plt>
mov    %r12,%rdi
call   1060 <range@plt>
mov    $0x4ce,%edi
mov    %eax,%esi
call   1040 <check_int@plt>
mov    %r14,%rsp
mov    %rsp,%r14
mov    0x0(%r13),%eax
add    $0x1,%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rbx,%rdi
call   1090 <tmpnam@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1070 <fopen@plt>
mov    %rax,%rdi
call   1030 <fclose@plt>
xor    %edi,%edi
mov    %eax,%esi
call   1040 <check_int@plt>
mov    %rbx,%rdi
call   1060 <range@plt>
mov    $0x1,%edi
mov    %eax,%esi
call   1040 <check_int@plt>
mov    %r14,%rsp
mov    0x0(%r13),%eax
add    $0x1,%eax
mov    %rsp,%r12
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
mov    %r12,%rdi
call   1090 <tmpnam@plt>
mov    %r12,%rdi
mov    %r15,%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
mov    $0x5,%esi
mov    $0x1,%edx
lea    0xd3d(%rip),%rdi
mov    %rax,%rcx
call   1080 <fwrite@plt>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1050 <fputc@plt>
lea    0xd2c(%rip),%rdi
mov    $0x3,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1080 <fwrite@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %edi,%edi
mov    %eax,%esi
call   1040 <check_int@plt>
mov    %r12,%rdi
call   1060 <range@plt>
mov    $0xffffffff,%edi
mov    %eax,%esi
call   1040 <check_int@plt>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@L_tmpnam = global i32 0
@.str = [2 x i8] c"w\00"
@.str.1 = [6 x i8] c"1231\0A\00"
@.str.2 = [3 x i8] c"1\0A\00"
@.str.3 = [5 x i8] c"441\0A\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [4 x i8] c"22\0A\00"
define i32 @main() {
%1 = alloca i8*
%2 = alloca i64
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32*
%10 = load i32, i32* @L_tmpnam
%11 = add nsw i32 %10, 1
%12 = zext i32 %11 to i64
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %1
%14 = alloca i8, i64 %12
store i64 %12, i64* %2
%15 = call i32 @tmpnam(i8* %14)
%16 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %16, i32** %3
%17 = load i32*, i32** %3
%18 = call i32 @fputs(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %17)
%19 = load i32*, i32** %3
%20 = call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %19)
%21 = load i32*, i32** %3
%22 = call i32 @fputs(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32* %21)
%23 = load i32*, i32** %3
%24 = call i32 @fclose(i32* %23)
%25 = call i32 @check_int(i32 0, i32 %24)
%26 = call i32 @range(i8* %14)
%27 = call i32 @check_int(i32 1230, i32 %26)
%28 = load i8*, i8** %1
%29 = load i32, i32* @L_tmpnam
%30 = add nsw i32 %29, 1
%31 = zext i32 %30 to i64
%32 = call i8* @llvm.stacksave()
store i8* %32, i8** %4
%33 = alloca i8, i64 %31
store i64 %31, i64* %5
%34 = call i32 @tmpnam(i8* %33)
%35 = call i32* @fopen(i8* %33, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %35, i32** %6
%36 = load i32*, i32** %6
%37 = call i32 @fclose(i32* %36)
%38 = call i32 @check_int(i32 0, i32 %37)
%39 = call i32 @range(i8* %33)
%40 = call i32 @check_int(i32 1, i32 %39)
%41 = load i8*, i8** %4
%42 = load i32, i32* @L_tmpnam
%43 = add nsw i32 %42, 1
%44 = zext i32 %43 to i64
%45 = call i8* @llvm.stacksave()
store i8* %45, i8** %7
%46 = alloca i8, i64 %44
store i64 %44, i64* %8
%47 = call i32 @tmpnam(i8* %46)
%48 = call i32* @fopen(i8* %46, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %48, i32** %9
%49 = load i32*, i32** %9
%50 = call i32 @fputs(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %49)
%51 = load i32*, i32** %9
%52 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32* %51)
%53 = load i32*, i32** %9
%54 = call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32* %53)
%55 = load i32*, i32** %9
%56 = call i32 @fclose(i32* %55)
%57 = call i32 @check_int(i32 0, i32 %56)
%58 = call i32 @range(i8* %46)
%59 = call i32 @check_int(i32 -1, i32 %58)
%60 = load i8*, i8** %7
ret i32 0
}

LLVM IR (-O2):
@L_tmpnam = global i32 0
@.str = [2 x i8] c"w\00"
@.str.1 = [6 x i8] c"1231\0A\00"
@.str.2 = [3 x i8] c"1\0A\00"
@.str.3 = [5 x i8] c"441\0A\00"
@.str.5 = [4 x i8] c"22\0A\00"
define i32 @main() {
%1 = load i32, i32* @L_tmpnam
%2 = add nsw i32 %1, 1
%3 = zext i32 %2 to i64
%4 = tail call i8* @llvm.stacksave()
%5 = alloca i8, i64 %3
%6 = call i32 @tmpnam(i8* %5)
%7 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = call i64 @fwrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 5, i64 1, i32* %7)
%9 = call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i64 2, i64 1, i32* %7)
%10 = call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i64 4, i64 1, i32* %7)
%11 = call i32 @fclose(i32* %7)
%12 = call i32 @check_int(i32 0, i32 %11)
%13 = call i32 @range(i8* %5)
%14 = call i32 @check_int(i32 1230, i32 %13)
%15 = load i32, i32* @L_tmpnam
%16 = add nsw i32 %15, 1
%17 = zext i32 %16 to i64
%18 = call i8* @llvm.stacksave()
%19 = alloca i8, i64 %17
%20 = call i32 @tmpnam(i8* %19)
%21 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%22 = call i32 @fclose(i32* %21)
%23 = call i32 @check_int(i32 0, i32 %22)
%24 = call i32 @range(i8* %19)
%25 = call i32 @check_int(i32 1, i32 %24)
%26 = load i32, i32* @L_tmpnam
%27 = add nsw i32 %26, 1
%28 = zext i32 %27 to i64
%29 = alloca i8, i64 %28
%30 = call i32 @tmpnam(i8* %29)
%31 = call i32* @fopen(i8* %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%32 = call i64 @fwrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 5, i64 1, i32* %31)
%33 = call i32 @fputc(i32 10, i32* %31)
%34 = call i64 @fwrite(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i64 3, i64 1, i32* %31)
%35 = call i32 @fclose(i32* %31)
%36 = call i32 @check_int(i32 0, i32 %35)
%37 = call i32 @range(i8* %29)
%38 = call i32 @check_int(i32 -1, i32 %37)
ret i32 0
}