#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 uid_t;

/* Variables and functions */
int execl(char *, char *, char *, char *, char *, char *, char *);
int getuid();
int /*<<< orphan*/ snprintf(char *, int, char *, int);
int main(int argc, char **argv) {
  if (argc != 2)
    return 1;
  uid_t realuser = getuid();
  char uidstring[20];
  snprintf(uidstring, 19, "%i", realuser);
  uidstring[19] = '\0';
  return execl("/usr/sbin/chown", "/usr/sbin/chown", "-R", "-h", uidstring,
               argv[1], (char *)0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     115c <main+0x2c>
movl   $0x1,-0x4(%rbp)
jmp    11b8 <main+0x88>
mov    $0x0,%al
call   1030 <getuid@plt>
mov    %eax,-0x14(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x14(%rbp),%ecx
mov    $0x13,%esi
lea    0xe87(%rip),%rdx
call   1040 <snprintf@plt>
movb   $0x0,-0x1d(%rbp)
lea    -0x30(%rbp),%r8
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%r9
lea    0xe6e(%rip),%rsi
lea    0xe77(%rip),%rdx
lea    0xe73(%rip),%rcx
xor    %eax,%eax
mov    %rsi,%rdi
movq   $0x0,(%rsp)
call   1050 <execl@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
mov    $0x1,%eax
cmp    $0x2,%edi
jne    119e <main+0x6e>
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbx
xor    %eax,%eax
call   1030 <getuid@plt>
lea    0xeae(%rip),%rdx
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    $0x13,%esi
mov    %eax,%ecx
call   1040 <snprintf@plt>
movb   $0x0,0x23(%rsp)
mov    0x8(%rbx),%r9
movq   $0x0,(%rsp)
lea    0xe85(%rip),%rdi
lea    0xe8e(%rip),%rdx
lea    0xe8a(%rip),%rcx
mov    %rdi,%rsi
mov    %r14,%r8
call   1050 <execl@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%i\00"
@.str.1 = [16 x i8] c"/usr/sbin/chown\00"
@.str.2 = [3 x i8] c"-R\00"
@.str.3 = [3 x i8] c"-h\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [20 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 2
br i1 %9, label %10, label %11
10: ; preds = %2
store i32 1, i32* %3
br label %22
11: ; preds = %2
%12 = call i32 (...) @getuid()
store i32 %12, i32* %6
%13 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%14 = load i32, i32* %6
%15 = call i32 @snprintf(i8* %13, i32 19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 19
store i8 0, i8* %16
%17 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @execl(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %17, i8* %20, i8* null)
store i32 %21, i32* %3
br label %22
22: ; preds = %11, %10
%23 = load i32, i32* %3
ret i32 %23
}

LLVM IR (-O2):
@.str = [3 x i8] c"%i\00"
@.str.1 = [16 x i8] c"/usr/sbin/chown\00"
@.str.2 = [3 x i8] c"-R\00"
@.str.3 = [3 x i8] c"-h\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [20 x i8]
%4 = icmp eq i32 %0, 2
br i1 %4, label %5, label %13
5: ; preds = %2
%6 = tail call i32 (...) @getuid()
%7 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%8 = call i32 @snprintf(i8* %7, i32 19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %6)
%9 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 19
store i8 0, i8* %9
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = call i32 @execl(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %7, i8* %11, i8* null)
br label %13
13: ; preds = %2, %5
%14 = phi i32 [ %12, %5 ], [ 1, %2 ]
ret i32 %14
}