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

/* Variables and functions */
scalar_t__ atoi(char *);
scalar_t__ chown(char *, scalar_t__, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  int i;
  if (argc <= 2) {
    fprintf(stderr, "usage: %s uid:gid fichier\n", argv[0]);
  } else {
    uid_t uid = atoi(argv[1]);
    if (uid != (uid_t)(-1)) {
      for (i = 2; i < argc; i++) {
        if (chown(argv[i], uid, -1) != 0) {
          fprintf(stderr, "Le fichier %s n'existe pas.\n", argv[i]);
        } else {
          printf("Changement des droits de %s, ok.\n", argv[i]);
        }
      }
    }
  }
  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   $0x2,-0x8(%rbp)
jg     1181 <main+0x41>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe89(%rip),%rsi
call   1040 <fprintf@plt>
jmp    122f <main+0xef>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0xffffffffffffffff,-0x20(%rbp)
je     122a <main+0xea>
movl   $0x2,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1225 <main+0xe5>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x20(%rbp),%rsi
mov    $0xffffffff,%edx
call   1050 <chown@plt>
cmp    $0x0,%rax
je     11fa <main+0xba>
mov    0x2e05(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe2b(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1212 <main+0xd2>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe2b(%rip),%rdi
call   1030 <printf@plt>
jmp    1217 <main+0xd7>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a4 <main+0x64>
jmp    122a <main+0xea>
jmp    122f <main+0xef>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x2,%edi
jg     116d <main+0x2d>
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe9a(%rip),%rsi
call   1040 <fprintf@plt>
jmp    11e0 <main+0xa0>
mov    %edi,%ebp
mov    0x8(%rbx),%rdi
call   1060 <atoi@plt>
cmp    $0xffffffffffffffff,%rax
je     11e0 <main+0xa0>
mov    %rax,%r14
mov    %ebp,%r13d
mov    $0x2,%ebp
mov    0x2e50(%rip),%r15
lea    0xe84(%rip),%r12
jmp    11b9 <main+0x79>
nopl   0x0(%rax)
mov    (%rbx,%rbp,8),%rsi
lea    0xe8d(%rip),%rdi
call   1030 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r13
je     11e0 <main+0xa0>
mov    (%rbx,%rbp,8),%rdi
mov    %r14,%rsi
mov    $0xffffffff,%edx
call   1050 <chown@plt>
test   %rax,%rax
je     11a0 <main+0x60>
mov    (%r15),%edi
mov    (%rbx,%rbp,8),%rdx
mov    %r12,%rsi
call   1040 <fprintf@plt>
jmp    11b0 <main+0x70>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [27 x i8] c"usage: %s uid:gid fichier\0A\00"
@.str.1 = [29 x i8] c"Le fichier %s n'existe pas.\0A\00"
@.str.2 = [34 x i8] c"Changement des droits de %s, ok.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp sle i32 %8, 2
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %14)
br label %58
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i64 @atoi(i8* %19)
store i64 %20, i64* %7
%21 = load i64, i64* %7
%22 = icmp ne i64 %21, -1
br i1 %22, label %23, label %57
23: ; preds = %16
store i32 2, i32* %6
br label %24
24: ; preds = %53, %23
%25 = load i32, i32* %6
%26 = load i32, i32* %4
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %56
28: ; preds = %24
%29 = load i8**, i8*** %5
%30 = load i32, i32* %6
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8*, i8** %29, i64 %31
%33 = load i8*, i8** %32
%34 = load i64, i64* %7
%35 = call i64 @chown(i8* %33, i64 %34, i32 -1)
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %45
37: ; preds = %28
%38 = load i32, i32* @stderr
%39 = load i8**, i8*** %5
%40 = load i32, i32* %6
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8*, i8** %39, i64 %41
%43 = load i8*, i8** %42
%44 = call i32 @fprintf(i32 %38, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %43)
br label %52
45: ; preds = %28
%46 = load i8**, i8*** %5
%47 = load i32, i32* %6
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8*, i8** %46, i64 %48
%50 = load i8*, i8** %49
%51 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %50)
br label %52
52: ; preds = %45, %37
br label %53
53: ; preds = %52
%54 = load i32, i32* %6
%55 = add nsw i32 %54, 1
store i32 %55, i32* %6
br label %24
56: ; preds = %24
br label %57
57: ; preds = %56, %16
br label %58
58: ; preds = %57, %10
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [27 x i8] c"usage: %s uid:gid fichier\0A\00"
@.str.1 = [29 x i8] c"Le fichier %s n'existe pas.\0A\00"
@.str.2 = [34 x i8] c"Changement des droits de %s, ok.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %31
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i64 @atoi(i8* %10)
%12 = icmp eq i64 %11, -1
br i1 %12, label %31, label %13
13: ; preds = %8
%14 = zext i32 %0 to i64
br label %15
15: ; preds = %13, %28
%16 = phi i64 [ 2, %13 ], [ %29, %28 ]
%17 = getelementptr inbounds i8*, i8** %1, i64 %16
%18 = load i8*, i8** %17
%19 = tail call i64 @chown(i8* %18, i64 %11, i32 -1)
%20 = icmp eq i64 %19, 0
br i1 %20, label %25, label %21
21: ; preds = %15
%22 = load i32, i32* @stderr
%23 = load i8*, i8** %17
%24 = tail call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %23)
br label %28
25: ; preds = %15
%26 = load i8*, i8** %17
%27 = tail call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %26)
br label %28
28: ; preds = %21, %25
%29 = add nuw nsw i64 %16, 1
%30 = icmp eq i64 %29, %14
br i1 %30, label %31, label %15
31: ; preds = %28, %8, %4
ret i32 0
}