#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 */
unsigned int getuid();
int /*<<< orphan*/ sprintf(char *, char *, unsigned int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void create_temppath(char *p) {
  unsigned int user_id;
  char tmp[20];
  user_id = getuid();
  strcpy(p, "/tmp/netio");
  sprintf(tmp, "%u", user_id);
  strcat(p, tmp);
  strcat(p, "/");
}


x86 assembly (clang, -O0):
<create_temppath>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1040 <getuid@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe9f(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x20(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xe97(%rip),%rsi
call   1060 <sprintf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <strcat@plt>
mov    -0x8(%rbp),%rdi
lea    0xe7d(%rip),%rsi
call   1050 <strcat@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_temppath>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%rbx
xor    %eax,%eax
call   1040 <getuid@plt>
mov    %eax,%ebp
lea    0xea5(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
lea    0xea1(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
mov    %ebp,%edx
call   1060 <sprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strcat@plt>
lea    0xe85(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcat@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"/tmp/netio\00"
@.str.1 = [3 x i8] c"%u\00"
@.str.2 = [2 x i8] c"/\00"
define void @create_temppath(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca [20 x i8]
store i8* %0, i8** %2
%5 = call i32 (...) @getuid()
store i32 %5, i32* %3
%6 = load i8*, i8** %2
%7 = call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%9 = load i32, i32* %3
%10 = call i32 @sprintf(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = load i8*, i8** %2
%12 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%13 = call i32 @strcat(i8* %11, i8* %12)
%14 = load i8*, i8** %2
%15 = call i32 @strcat(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"/tmp/netio\00"
@.str.1 = [3 x i8] c"%u\00"
@.str.2 = [2 x i8] c"/\00"
define void @create_temppath(i8* %0) {
%2 = alloca [20 x i8]
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%4 = tail call i32 (...) @getuid()
%5 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %4)
%7 = call i32 @strcat(i8* %0, i8* %3)
%8 = call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}