#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(int /*<<< orphan*/);
char *mkdtemp(char *);
int mkstemp(char *);
int /*<<< orphan*/ printf(char *, char *, ...);
int /*<<< orphan*/ rmdir(char *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ *tmpfile();
int /*<<< orphan*/ unlink(char *);
int main() {
  int fd;
  FILE *fp;
  char *f_mkdtemp;
  char template_file[] = "AAXXXXXX", template_dir[] = "BBXXXXXX";
  printf("template_file = %s\n", template_file);
  fd = mkstemp(template_file);
  printf("template_file = %s\n", template_file);
  f_mkdtemp = mkdtemp(template_dir);
  printf("f_mkdtemp = %s template_dir=%s\n", f_mkdtemp, template_dir);
  fp = tmpfile();
  sleep(10);
  unlink(template_file);
  rmdir(f_mkdtemp);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe6a(%rip),%rax
mov    %rax,-0x21(%rbp)
mov    0xe68(%rip),%al
mov    %al,-0x19(%rbp)
mov    0xe5f(%rip),%rax
mov    %rax,-0x2a(%rbp)
mov    0xe5d(%rip),%al
mov    %al,-0x22(%rbp)
lea    -0x21(%rbp),%rsi
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x21(%rbp),%rdi
call   1070 <mkstemp@plt>
mov    %eax,-0x8(%rbp)
lea    -0x21(%rbp),%rsi
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x2a(%rbp),%rdi
call   1080 <mkdtemp@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    -0x2a(%rbp),%rdx
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1060 <tmpfile@plt>
mov    %rax,-0x10(%rbp)
mov    $0xa,%edi
call   10a0 <sleep@plt>
lea    -0x21(%rbp),%rdi
call   1030 <unlink@plt>
mov    -0x18(%rbp),%rdi
call   1040 <rmdir@plt>
xor    %edi,%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
movabs $0x5858585858584141,%rax
58 58 58
mov    %rax,0x10(%rsp)
movb   $0x0,0x18(%rsp)
movabs $0x5858585858584242,%rax
58 58 58
mov    %rax,(%rsp)
movb   $0x0,0x8(%rsp)
lea    0xe5b(%rip),%r14
lea    0x10(%rsp),%r15
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
call   1070 <mkstemp@plt>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rsp,%r14
mov    %r14,%rdi
call   1080 <mkdtemp@plt>
mov    %rax,%rbx
lea    0xe33(%rip),%rdi
mov    %rax,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1060 <tmpfile@plt>
mov    $0xa,%edi
call   10a0 <sleep@plt>
mov    %r15,%rdi
call   1030 <unlink@plt>
mov    %rbx,%rdi
call   1040 <rmdir@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@__const.main.template_file = [9 x i8] c"AAXXXXXX\00"
@__const.main.template_dir = [9 x i8] c"BBXXXXXX\00"
@.str = [20 x i8] c"template_file = %s\0A\00"
@.str.1 = [32 x i8] c"f_mkdtemp = %s template_dir=%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca [9 x i8]
%6 = alloca [9 x i8]
store i32 0, i32* %1
%7 = bitcast [9 x i8]* %5 to i8*
%8 = bitcast [9 x i8]* %6 to i8*
%9 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 0
%10 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 0
%12 = call i32 @mkstemp(i8* %11)
store i32 %12, i32* %2
%13 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 0
%14 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = getelementptr inbounds [9 x i8], [9 x i8]* %6, i64 0, i64 0
%16 = call i8* @mkdtemp(i8* %15)
store i8* %16, i8** %4
%17 = load i8*, i8** %4
%18 = getelementptr inbounds [9 x i8], [9 x i8]* %6, i64 0, i64 0
%19 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %17, i8* %18)
%20 = call i32* (...) @tmpfile()
store i32* %20, i32** %3
%21 = call i32 @sleep(i32 10)
%22 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 0
%23 = call i32 @unlink(i8* %22)
%24 = load i8*, i8** %4
%25 = call i32 @rmdir(i8* %24)
%26 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@__const.main.template_file = [9 x i8] c"AAXXXXXX\00"
@__const.main.template_dir = [9 x i8] c"BBXXXXXX\00"
@.str = [20 x i8] c"template_file = %s\0A\00"
@.str.1 = [32 x i8] c"f_mkdtemp = %s template_dir=%s\0A\00"
define i32 @main() {
%1 = alloca [9 x i8]
%2 = alloca [9 x i8]
%3 = getelementptr inbounds [9 x i8], [9 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
%5 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %3)
%6 = call i32 @mkstemp(i8* %3)
%7 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %3)
%8 = call i8* @mkdtemp(i8* %4)
%9 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %8, i8* %4)
%10 = call i32* (...) @tmpfile()
%11 = call i32 @sleep(i32 10)
%12 = call i32 @unlink(i8* %3)
%13 = call i32 @rmdir(i8* %8)
%14 = call i32 @exit(i32 0)
unreachable
}