#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 atoi(char *);
int chown(char *, int, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  if (argc != 3 || argv[1][0] == '\0') {
    fprintf(stderr, "%s <owner> <file>\n", argv[0]);
  } else {
    int id = atoi(argv[1]);
    printf("id -> %d\n", id);
    int r = chown(argv[2], id, id);
    if (r != -1) {
      printf("chown success\n");
    } else {
      printf("chown error\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jne    1174 <main+0x34>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1195 <main+0x55>
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe75(%rip),%rsi
call   1040 <fprintf@plt>
jmp    11fc <main+0xbc>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x14(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1050 <chown@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
je     11e9 <main+0xa9>
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f7 <main+0xb7>
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11fc <main+0xbc>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x3,%edi
jne    1196 <main+0x46>
mov    0x8(%rbx),%rdi
cmpb   $0x0,(%rdi)
je     1196 <main+0x46>
call   1070 <atoi@plt>
mov    %eax,%ebp
lea    0xea1(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rbx),%rdi
mov    %ebp,%esi
mov    %ebp,%edx
call   1060 <chown@plt>
cmp    $0xffffffff,%eax
je     11b0 <main+0x60>
lea    0xe95(%rip),%rdi
jmp    11b7 <main+0x67>
mov    0x2e43(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe57(%rip),%rsi
call   1050 <fprintf@plt>
jmp    11bc <main+0x6c>
lea    0xe66(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [19 x i8] c"%s <owner> <file>\0A\00"
@.str.1 = [10 x i8] c"id -> %d\0A\00"
@.str.2 = [15 x i8] c"chown success\0A\00"
@.str.3 = [13 x i8] c"chown error\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
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, 3
br i1 %9, label %18, label %10
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = getelementptr inbounds i8, i8* %13, i64 0
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %24
18: ; preds = %10, %2
%19 = load i32, i32* @stderr
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 0
%22 = load i8*, i8** %21
%23 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %22)
br label %44
24: ; preds = %10
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i32 @atoi(i8* %27)
store i32 %28, i32* %6
%29 = load i32, i32* %6
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %29)
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 2
%33 = load i8*, i8** %32
%34 = load i32, i32* %6
%35 = load i32, i32* %6
%36 = call i32 @chown(i8* %33, i32 %34, i32 %35)
store i32 %36, i32* %7
%37 = load i32, i32* %7
%38 = icmp ne i32 %37, -1
br i1 %38, label %39, label %41
39: ; preds = %24
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %43
41: ; preds = %24
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %43
43: ; preds = %41, %39
br label %44
44: ; preds = %43, %18
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [19 x i8] c"%s <owner> <file>\0A\00"
@.str.1 = [10 x i8] c"id -> %d\0A\00"
@str = [12 x i8] c"chown error\00"
@str.4 = [14 x i8] c"chown success\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %4, %2
%10 = load i32, i32* @stderr
%11 = load i8*, i8** %1
%12 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %11)
br label %24
13: ; preds = %4
%14 = tail call i32 @atoi(i8* %6)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = getelementptr inbounds i8*, i8** %1, i64 2
%17 = load i8*, i8** %16
%18 = tail call i32 @chown(i8* %17, i32 %14, i32 %14)
%19 = icmp eq i32 %18, -1
br i1 %19, label %22, label %20
20: ; preds = %13
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.4, i64 0, i64 0))
br label %24
22: ; preds = %13
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
br label %24
24: ; preds = %20, %22, %9
ret i32 0
}