#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*/ check_valid_formats(int, char *);
int /*<<< orphan*/ close(int);
int mkstemp(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ unlink(char *);
int main(int argc __attribute__((unused)),
         char **argv __attribute__((unused))) {
  int fd = 0;
  char tmpname[] = "evemu.tmp.XXXXXXX";
  if ((fd = mkstemp(tmpname)) == -1) {
    perror("");
    return 1;
  }
  check_valid_formats(fd, tmpname);
  close(fd);
  unlink(tmpname);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    0xe8c(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xe89(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xe86(%rip),%ax
mov    %ax,-0x20(%rbp)
lea    -0x30(%rbp),%rdi
call   1050 <mkstemp@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
jne    11bb <main+0x6b>
lea    0xe68(%rip),%rdi
call   1060 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    11df <main+0x8f>
mov    -0x14(%rbp),%edi
lea    -0x30(%rbp),%rsi
call   1070 <check_valid_formats@plt>
mov    -0x14(%rbp),%edi
call   1040 <close@plt>
lea    -0x30(%rbp),%rdi
call   1030 <unlink@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movaps 0xea2(%rip),%xmm0
movaps %xmm0,(%rsp)
movw   $0x58,0x10(%rsp)
mov    %rsp,%rdi
call   1050 <mkstemp@plt>
cmp    $0xffffffff,%eax
je     119e <main+0x4e>
mov    %eax,%ebx
mov    %rsp,%r14
mov    %eax,%edi
mov    %r14,%rsi
call   1070 <check_valid_formats@plt>
mov    %ebx,%edi
call   1040 <close@plt>
mov    %r14,%rdi
call   1030 <unlink@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe6d(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%eax
jmp    1196 <main+0x46>

LLVM IR (-O0):
@__const.main.tmpname = [18 x i8] c"evemu.tmp.XXXXXXX\00"
@.str = [1 x i8] zeroinitializer
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [18 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%8 = bitcast [18 x i8]* %7 to i8*
%9 = getelementptr inbounds [18 x i8], [18 x i8]* %7, i64 0, i64 0
%10 = call i32 @mkstemp(i8* %9)
store i32 %10, i32* %6
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 @perror(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %22
14: ; preds = %2
%15 = load i32, i32* %6
%16 = getelementptr inbounds [18 x i8], [18 x i8]* %7, i64 0, i64 0
%17 = call i32 @check_valid_formats(i32 %15, i8* %16)
%18 = load i32, i32* %6
%19 = call i32 @close(i32 %18)
%20 = getelementptr inbounds [18 x i8], [18 x i8]* %7, i64 0, i64 0
%21 = call i32 @unlink(i8* %20)
store i32 0, i32* %3
br label %22
22: ; preds = %14, %12
%23 = load i32, i32* %3
ret i32 %23
}

LLVM IR (-O2):
@__const.main.tmpname = [18 x i8] c"evemu.tmp.XXXXXXX\00"
@.str = [1 x i8] zeroinitializer
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [18 x i8]
%4 = getelementptr inbounds [18 x i8], [18 x i8]* %3, i64 0, i64 0
%5 = call i32 @mkstemp(i8* %4)
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = call i32 @perror(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %13
9: ; preds = %2
%10 = call i32 @check_valid_formats(i32 %5, i8* %4)
%11 = call i32 @close(i32 %5)
%12 = call i32 @unlink(i8* %4)
br label %13
13: ; preds = %9, %7
%14 = phi i32 [ 1, %7 ], [ 0, %9 ]
ret i32 %14
}