#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*/ printf(char *, ...);
char *tmpnam(char *);
int main(void) {
  int i;
  char des_name[20] = "testname";
  char *ret_name;
  for (i = 0; i < 10; i++) {
    ret_name = tmpnam(des_name);
    if (ret_name != NULL)
      printf("%s\n", ret_name);
    else
      printf("creat err!\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xec5(%rip),%eax
mov    %eax,-0x10(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    11af <main+0x8f>
lea    -0x20(%rbp),%rdi
call   1040 <tmpnam@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     118e <main+0x6e>
mov    -0x28(%rbp),%rsi
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    119c <main+0x7c>
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a1 <main+0x81>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1155 <main+0x35>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
movaps 0xed5(%rip),%xmm0
movaps %xmm0,(%rsp)
movl   $0x0,0x10(%rsp)
mov    %rsp,%rdi
call   1040 <tmpnam@plt>
test   %rax,%rax
je     1149 <main+0x29>
mov    %rax,%rdi
jmp    1150 <main+0x30>
lea    0xec4(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rdi
call   1040 <tmpnam@plt>
test   %rax,%rax
je     1167 <main+0x47>
mov    %rax,%rdi
jmp    116e <main+0x4e>
lea    0xea6(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rdi
call   1040 <tmpnam@plt>
test   %rax,%rax
je     1185 <main+0x65>
mov    %rax,%rdi
jmp    118c <main+0x6c>
lea    0xe88(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rdi
call   1040 <tmpnam@plt>
test   %rax,%rax
je     11a3 <main+0x83>
mov    %rax,%rdi
jmp    11aa <main+0x8a>
lea    0xe6a(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rdi
call   1040 <tmpnam@plt>
test   %rax,%rax
je     11c1 <main+0xa1>
mov    %rax,%rdi
jmp    11c8 <main+0xa8>
lea    0xe4c(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rdi
call   1040 <tmpnam@plt>
test   %rax,%rax
je     11df <main+0xbf>
mov    %rax,%rdi
jmp    11e6 <main+0xc6>
lea    0xe2e(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rdi
call   1040 <tmpnam@plt>
test   %rax,%rax
je     11fd <main+0xdd>
mov    %rax,%rdi
jmp    1204 <main+0xe4>
lea    0xe10(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rdi
call   1040 <tmpnam@plt>
test   %rax,%rax
je     121b <main+0xfb>
mov    %rax,%rdi
jmp    1222 <main+0x102>
lea    0xdf2(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rdi
call   1040 <tmpnam@plt>
test   %rax,%rax
je     1239 <main+0x119>
mov    %rax,%rdi
jmp    1240 <main+0x120>
lea    0xdd4(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rdi
call   1040 <tmpnam@plt>
test   %rax,%rax
je     1257 <main+0x137>
mov    %rax,%rdi
jmp    125e <main+0x13e>
lea    0xdb6(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@__const.main.des_name = [20 x i8] c"testname\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [12 x i8] c"creat err!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [20 x i8]
%4 = alloca i8*
store i32 0, i32* %1
%5 = bitcast [20 x i8]* %3 to i8*
store i32 0, i32* %2
br label %6
6: ; preds = %20, %0
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 10
br i1 %8, label %9, label %23
9: ; preds = %6
%10 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%11 = call i8* @tmpnam(i8* %10)
store i8* %11, i8** %4
%12 = load i8*, i8** %4
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %17
14: ; preds = %9
%15 = load i8*, i8** %4
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %15)
br label %19
17: ; preds = %9
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %19
19: ; preds = %17, %14
br label %20
20: ; preds = %19
%21 = load i32, i32* %2
%22 = add nsw i32 %21, 1
store i32 %22, i32* %2
br label %6
23: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@__const.main.des_name = [20 x i8] c"testname\00\00\00\00\00\00\00\00\00\00\00\00"
@str = [11 x i8] c"creat err!\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%3 = call i8* @tmpnam(i8* %2)
%4 = icmp eq i8* %3, null
br i1 %4, label %7, label %5
5: ; preds = %0
%6 = call i32 @puts(i8* %3)
br label %9
7: ; preds = %0
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
br label %9
9: ; preds = %5, %7
%10 = call i8* @tmpnam(i8* %2)
%11 = icmp eq i8* %10, null
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = call i32 @puts(i8* %10)
br label %16
14: ; preds = %9
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
br label %16
16: ; preds = %14, %12
%17 = call i8* @tmpnam(i8* %2)
%18 = icmp eq i8* %17, null
br i1 %18, label %21, label %19
19: ; preds = %16
%20 = call i32 @puts(i8* %17)
br label %23
21: ; preds = %16
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
br label %23
23: ; preds = %21, %19
%24 = call i8* @tmpnam(i8* %2)
%25 = icmp eq i8* %24, null
br i1 %25, label %28, label %26
26: ; preds = %23
%27 = call i32 @puts(i8* %24)
br label %30
28: ; preds = %23
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
br label %30
30: ; preds = %28, %26
%31 = call i8* @tmpnam(i8* %2)
%32 = icmp eq i8* %31, null
br i1 %32, label %35, label %33
33: ; preds = %30
%34 = call i32 @puts(i8* %31)
br label %37
35: ; preds = %30
%36 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
br label %37
37: ; preds = %35, %33
%38 = call i8* @tmpnam(i8* %2)
%39 = icmp eq i8* %38, null
br i1 %39, label %42, label %40
40: ; preds = %37
%41 = call i32 @puts(i8* %38)
br label %44
42: ; preds = %37
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
br label %44
44: ; preds = %42, %40
%45 = call i8* @tmpnam(i8* %2)
%46 = icmp eq i8* %45, null
br i1 %46, label %49, label %47
47: ; preds = %44
%48 = call i32 @puts(i8* %45)
br label %51
49: ; preds = %44
%50 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
br label %51
51: ; preds = %49, %47
%52 = call i8* @tmpnam(i8* %2)
%53 = icmp eq i8* %52, null
br i1 %53, label %56, label %54
54: ; preds = %51
%55 = call i32 @puts(i8* %52)
br label %58
56: ; preds = %51
%57 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
br label %58
58: ; preds = %56, %54
%59 = call i8* @tmpnam(i8* %2)
%60 = icmp eq i8* %59, null
br i1 %60, label %63, label %61
61: ; preds = %58
%62 = call i32 @puts(i8* %59)
br label %65
63: ; preds = %58
%64 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
br label %65
65: ; preds = %63, %61
%66 = call i8* @tmpnam(i8* %2)
%67 = icmp eq i8* %66, null
br i1 %67, label %70, label %68
68: ; preds = %65
%69 = call i32 @puts(i8* %66)
br label %72
70: ; preds = %65
%71 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
br label %72
72: ; preds = %70, %68
ret i32 0
}