#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*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
char *tempnam(char *, char *);
int main(int argc, char *argv[]) {
  char *f_tmp_path;
  FILE *f_tmp;
  if ((f_tmp_path = tempnam(".MIADIR", "tmp-")) == NULL) {
    fprintf(stderr, "%s: Generazione file temporaneo\n", strerror(errno));
    exit(EXIT_FAILURE);
  }
  printf("Nome del file temporaneo: %s\n", f_tmp_path);
  if ((f_tmp = fopen(f_tmp_path, "w+")) == NULL) {
    fprintf(stderr, "%s: Apertura file\n", strerror(errno));
    exit(EXIT_FAILURE);
  }
  fputs("The art of *nix programming\n", f_tmp);
  fclose(f_tmp);
  free(f_tmp_path);
  return (EXIT_SUCCESS);
}


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)
lea    0xe53(%rip),%rdi
lea    0xe54(%rip),%rsi
call   1080 <tempnam@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1201 <main+0x71>
mov    0x2e12(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    0x2dfe(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0x24(%rbp),%edi
mov    %rax,%rdx
lea    0xe1f(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2dd6(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    -0x18(%rbp),%rsi
lea    0xe22(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe30(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1269 <main+0xd9>
mov    0x2daa(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    0x2d96(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0x28(%rbp),%edi
mov    %rax,%rdx
lea    0xdf9(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2d6e(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    -0x20(%rbp),%rsi
lea    0xdee(%rip),%rdi
call   1060 <fputs@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    0x2d36(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xe65(%rip),%rdi
lea    0xe66(%rip),%rsi
call   1070 <tempnam@plt>
test   %rax,%rax
je     120f <main+0x7f>
mov    %rax,%r14
lea    0xe78(%rip),%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
lea    0xe87(%rip),%rsi
mov    %r14,%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     122f <main+0x9f>
mov    %rax,%rbx
lea    0xe86(%rip),%rdi
mov    $0x1c,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   10a0 <fwrite@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    0x2dc3(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2dca(%rip),%rax
mov    (%rax),%ebx
mov    0x2db9(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
lea    0xde0(%rip),%rsi
jmp    124d <main+0xbd>
mov    0x2daa(%rip),%rax
mov    (%rax),%ebx
mov    0x2d99(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
lea    0xe02(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1060 <fprintf@plt>
mov    0x2d72(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [8 x i8] c".MIADIR\00"
@.str.1 = [5 x i8] c"tmp-\00"
@stderr = global i32 0
@.str.2 = [33 x i8] c"%s: Generazione file temporaneo\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@.str.3 = [30 x i8] c"Nome del file temporaneo: %s\0A\00"
@.str.4 = [3 x i8] c"w+\00"
@.str.5 = [19 x i8] c"%s: Apertura file\0A\00"
@.str.6 = [29 x i8] c"The art of *nix programming\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i8* @tempnam(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i8* %8, i8** %6
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %17
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i32, i32* @errno
%13 = call i8* @strerror(i32 %12)
%14 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* %13)
%15 = load i32, i32* @EXIT_FAILURE
%16 = call i32 @exit(i32 %15)
unreachable
17: ; preds = %2
%18 = load i8*, i8** %6
%19 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i8* %18)
%20 = load i8*, i8** %6
%21 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %21, i32** %7
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %30
23: ; preds = %17
%24 = load i32, i32* @stderr
%25 = load i32, i32* @errno
%26 = call i8* @strerror(i32 %25)
%27 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i8* %26)
%28 = load i32, i32* @EXIT_FAILURE
%29 = call i32 @exit(i32 %28)
unreachable
30: ; preds = %17
%31 = load i32*, i32** %7
%32 = call i32 @fputs(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), i32* %31)
%33 = load i32*, i32** %7
%34 = call i32 @fclose(i32* %33)
%35 = load i8*, i8** %6
%36 = call i32 @free(i8* %35)
%37 = load i32, i32* @EXIT_SUCCESS
ret i32 %37
}

LLVM IR (-O2):
@.str = [8 x i8] c".MIADIR\00"
@.str.1 = [5 x i8] c"tmp-\00"
@stderr = global i32 0
@.str.2 = [33 x i8] c"%s: Generazione file temporaneo\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@.str.3 = [30 x i8] c"Nome del file temporaneo: %s\0A\00"
@.str.4 = [3 x i8] c"w+\00"
@.str.5 = [19 x i8] c"%s: Apertura file\0A\00"
@.str.6 = [29 x i8] c"The art of *nix programming\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i8* @tempnam(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i8* %3, null
br i1 %4, label %5, label %12
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = load i32, i32* @errno
%8 = tail call i8* @strerror(i32 %7)
%9 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %2
%13 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i8* %3)
%14 = tail call i32* @fopen(i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %23
16: ; preds = %12
%17 = load i32, i32* @stderr
%18 = load i32, i32* @errno
%19 = tail call i8* @strerror(i32 %18)
%20 = tail call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i8* %19)
%21 = load i32, i32* @EXIT_FAILURE
%22 = tail call i32 @exit(i32 %21)
unreachable
23: ; preds = %12
%24 = tail call i64 @fwrite(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), i64 28, i64 1, i32* %14)
%25 = tail call i32 @fclose(i32* %14)
%26 = tail call i32 @free(i8* %3)
%27 = load i32, i32* @EXIT_SUCCESS
ret i32 %27
}