#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*/ str;
typedef int pid_t;
typedef int /*<<< orphan*/ outpath;
typedef int /*<<< orphan*/ outname;

/* Variables and functions */
int /*<<< orphan*/ P_tmpdir;
int /*<<< orphan*/ get_cmyk_color_suf(int);
int /*<<< orphan*/ pathcat(char *, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, ...);
char const *strdup(char *);
int /*<<< orphan*/ strncpy(char *, int /*<<< orphan*/, int);
const char *get_tmp_file_name(const char *fsuf, pid_t pid, int fidx,
                              int color_idx) {
  char outpath[4096];
  char outname[4096];
  char str[4096];
  strncpy(outpath, P_tmpdir, sizeof(outpath));
  snprintf(outname, sizeof(outname), "%u.%u.%s", pid, fidx, fsuf);
  pathcat(outpath, "/");
  snprintf(str, sizeof(str), "%s%s.%s", outpath, outname,
           get_cmyk_color_suf(color_idx));
  return strdup(str);
}


x86 assembly (clang, -O0):
<get_tmp_file_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3040,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
lea    -0x1020(%rbp),%rdi
mov    0x2e72(%rip),%rax
mov    (%rax),%esi
mov    $0x1000,%edx
call   1030 <strncpy@plt>
lea    -0x2020(%rbp),%rdi
mov    -0xc(%rbp),%ecx
mov    -0x10(%rbp),%r8d
mov    -0x8(%rbp),%r9
mov    $0x1000,%esi
lea    0xe60(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
lea    -0x1020(%rbp),%rdi
lea    0xe54(%rip),%rsi
call   1060 <pathcat@plt>
lea    -0x3020(%rbp),%rax
mov    %rax,-0x3038(%rbp)
lea    -0x1020(%rbp),%rax
mov    %rax,-0x3030(%rbp)
lea    -0x2020(%rbp),%rax
mov    %rax,-0x3028(%rbp)
mov    -0x14(%rbp),%edi
call   1050 <get_cmyk_color_suf@plt>
mov    -0x3038(%rbp),%rdi
mov    -0x3030(%rbp),%rcx
mov    -0x3028(%rbp),%r8
mov    %eax,%r9d
mov    $0x1000,%esi
lea    0xdfb(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
lea    -0x3020(%rbp),%rdi
call   1070 <strdup@plt>
add    $0x3040,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_tmp_file_name>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x3008,%rsp
mov    %ecx,%r15d
mov    %edx,%r12d
mov    %esi,%ebp
mov    %rdi,%rbx
mov    0x2e75(%rip),%rax
mov    (%rax),%esi
lea    0x2000(%rsp),%r14
mov    %r14,%rdi
mov    $0x1000,%edx
call   1030 <strncpy@plt>
lea    0xe6f(%rip),%rdx
lea    0x1000(%rsp),%r13
mov    %r13,%rdi
mov    $0x1000,%esi
mov    %ebp,%ecx
mov    %r12d,%r8d
mov    %rbx,%r9
xor    %eax,%eax
call   1040 <snprintf@plt>
lea    0xe52(%rip),%rsi
mov    %r14,%rdi
call   1060 <pathcat@plt>
mov    %r15d,%edi
call   1050 <get_cmyk_color_suf@plt>
lea    0xe3d(%rip),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x1000,%esi
mov    %r14,%rcx
mov    %r13,%r8
mov    %eax,%r9d
xor    %eax,%eax
call   1040 <snprintf@plt>
mov    %rbx,%rdi
call   1070 <strdup@plt>
add    $0x3008,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@P_tmpdir = global i32 0
@.str = [9 x i8] c"%u.%u.%s\00"
@.str.1 = [2 x i8] c"/\00"
@.str.2 = [8 x i8] c"%s%s.%s\00"
define i8* @get_tmp_file_name(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [4096 x i8]
%10 = alloca [4096 x i8]
%11 = alloca [4096 x i8]
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%12 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%13 = load i32, i32* @P_tmpdir
%14 = call i32 @strncpy(i8* %12, i32 %13, i32 4096)
%15 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
%16 = load i32, i32* %6
%17 = load i32, i32* %7
%18 = load i8*, i8** %5
%19 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %15, i32 4096, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %16, i32 %17, i8* %18)
%20 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%21 = call i32 @pathcat(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%22 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%23 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%24 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
%25 = load i32, i32* %8
%26 = call i32 @get_cmyk_color_suf(i32 %25)
%27 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %22, i32 4096, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %23, i8* %24, i32 %26)
%28 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%29 = call i8* @strdup(i8* %28)
ret i8* %29
}

LLVM IR (-O2):
@P_tmpdir = global i32 0
@.str = [9 x i8] c"%u.%u.%s\00"
@.str.1 = [2 x i8] c"/\00"
@.str.2 = [8 x i8] c"%s%s.%s\00"
define noalias i8* @get_tmp_file_name(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca [4096 x i8]
%6 = alloca [4096 x i8]
%7 = alloca [4096 x i8]
%8 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%9 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%10 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%11 = load i32, i32* @P_tmpdir
%12 = call i32 @strncpy(i8* %8, i32 %11, i32 4096)
%13 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %9, i32 4096, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %2, i8* %0)
%14 = call i32 @pathcat(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 @get_cmyk_color_suf(i32 %3)
%16 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %10, i32 4096, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %8, i8* %9, i32 %15)
%17 = call i8* @strdup(i8* %10)
ret i8* %17
}