#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*/ close(int);
int mkstemp(char *);
int /*<<< orphan*/ strcpy(char *, char const *);
int /*<<< orphan*/ strlen(char const *);
int /*<<< orphan*/ write(int, char const *, int /*<<< orphan*/);
void write_tmp_config(char *filename) {
  const char *template = "/tmp/bttracker.conf.XXXXXX";
  strcpy(filename, template);
  int fd = mkstemp(filename);
  const char *text =
      "[BtTracker]\nLogLevel=INFO\nAddress=0.0.0.0\nPort=1234\n\n[Threading]"
      "\nMaxThreads=4\nMaxIdleTime=300\n\n[Announce]\nInfoHashRestriction="
      "none\nWaitTime=1800\nPeerTTL=1920\nMaxNumWant=80\n\n[Redis]\nSocketPath="
      "/tmp/"
      "redis.sock\nHost=127.0.0.1\nPort=6379\nTimeout=500\nDB=1\nKeyPrefix="
      "bttracker";
  write(fd, text, strlen(text));
  close(fd);
}


x86 assembly (clang, -O0):
<write_tmp_config>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xe9d(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rdi
call   1070 <mkstemp@plt>
mov    %eax,-0x14(%rbp)
lea    0xe94(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_tmp_config>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xea2(%rip),%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1070 <mkstemp@plt>
mov    %eax,%ebx
lea    0xea7(%rip),%r14
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1060 <close@plt>

LLVM IR (-O0):
@.str = [27 x i8] c"/tmp/bttracker.conf.XXXXXX\00"
@.str.1 = [270 x i8] c"[BtTracker]\0ALogLevel=INFO\0AAddress=0.0.0.0\0APort=1234\0A\0A[Threading]\0AMaxThreads=4\0AMaxIdleTime=300\0A\0A[Announce]\0AInfoHashRestriction=none\0AWaitTime=1800\0APeerTTL=1920\0AMaxNumWant=80\0A\0A[Redis]\0ASocketPath=/tmp/redis.sock\0AHost=127.0.0.1\0APort=6379\0ATimeout=500\0ADB=1\0AKeyPrefix=bttracker\00"
define void @write_tmp_config(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
store i8* %0, i8** %2
store i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8** %3
%6 = load i8*, i8** %2
%7 = load i8*, i8** %3
%8 = call i32 @strcpy(i8* %6, i8* %7)
%9 = load i8*, i8** %2
%10 = call i32 @mkstemp(i8* %9)
store i32 %10, i32* %4
store i8* getelementptr inbounds ([270 x i8], [270 x i8]* @.str.1, i64 0, i64 0), i8** %5
%11 = load i32, i32* %4
%12 = load i8*, i8** %5
%13 = load i8*, i8** %5
%14 = call i32 @strlen(i8* %13)
%15 = call i32 @write(i32 %11, i8* %12, i32 %14)
%16 = load i32, i32* %4
%17 = call i32 @close(i32 %16)
ret void
}

LLVM IR (-O2):
@.str = [27 x i8] c"/tmp/bttracker.conf.XXXXXX\00"
@.str.1 = [270 x i8] c"[BtTracker]\0ALogLevel=INFO\0AAddress=0.0.0.0\0APort=1234\0A\0A[Threading]\0AMaxThreads=4\0AMaxIdleTime=300\0A\0A[Announce]\0AInfoHashRestriction=none\0AWaitTime=1800\0APeerTTL=1920\0AMaxNumWant=80\0A\0A[Redis]\0ASocketPath=/tmp/redis.sock\0AHost=127.0.0.1\0APort=6379\0ATimeout=500\0ADB=1\0AKeyPrefix=bttracker\00"
define void @write_tmp_config(i8* %0) {
%2 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @mkstemp(i8* %0)
%4 = tail call i32 @strlen(i8* getelementptr inbounds ([270 x i8], [270 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 @write(i32 %3, i8* getelementptr inbounds ([270 x i8], [270 x i8]* @.str.1, i64 0, i64 0), i32 %4)
%6 = tail call i32 @close(i32 %3)
ret void
}