main(argc, argv) int argc;
char *argv[];
{
  int i;
  int status = 0;
  int newmode;
  if (argc < 3) {
    Usage();
  }
  newmode = oatoi(argv[1]);
  for (i = 2; i < argc; i++) {
    if (access(argv[i], 0)) {
      prints("chmod: can't access %s\n", argv[i]);
      status++;
    } else if (chmod(argv[i], newmode) < 0) {
      prints("chmod: can't change %s\n", argv[i]);
      status++;
    }
  }
  exit(status);
}


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)
movl   $0x0,-0x18(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    118e <main+0x2e>
mov    $0x0,%al
call   1030 <Usage@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    $0x0,%al
call   1050 <oatoi@plt>
mov    %eax,-0x1c(%rbp)
movl   $0x2,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1253 <main+0xf3>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
xor    %esi,%esi
mov    $0x0,%al
call   1070 <access@plt>
cmp    $0x0,%eax
je     11f9 <main+0x99>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe1c(%rip),%rdi
mov    $0x0,%al
call   1040 <prints@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1240 <main+0xe0>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x1c(%rbp),%esi
mov    $0x0,%al
call   1060 <chmod@plt>
cmp    $0x0,%eax
jge    123b <main+0xdb>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1040 <prints@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1240 <main+0xe0>
jmp    1245 <main+0xe5>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a7 <main+0x47>
mov    -0x18(%rbp),%edi
call   1080 <exit@plt>

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     118e <main+0x2e>
xor    %ebp,%ebp
xor    %eax,%eax
call   1030 <Usage@plt>
mov    0x8(%rbx),%rdi
xor    %eax,%eax
call   1050 <oatoi@plt>
mov    %ebp,%edi
call   1080 <exit@plt>
mov    %edi,%ebp
mov    0x8(%rbx),%rdi
xor    %eax,%eax
call   1050 <oatoi@plt>
mov    %eax,%r14d
mov    %ebp,%r13d
mov    $0x2,%r15d
lea    0xe52(%rip),%r12
xor    %ebp,%ebp
jmp    11d6 <main+0x76>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <prints@plt>
add    $0x1,%ebp
add    $0x1,%r15
cmp    %r15,%r13
je     1209 <main+0xa9>
mov    (%rbx,%r15,8),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1070 <access@plt>
mov    (%rbx,%r15,8),%rsi
test   %eax,%eax
jne    11c0 <main+0x60>
mov    %rsi,%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1060 <chmod@plt>
test   %eax,%eax
jns    11cd <main+0x6d>
mov    (%rbx,%r15,8),%rsi
lea    0xe11(%rip),%rdi
jmp    11c3 <main+0x63>
mov    %ebp,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [24 x i8] c"chmod: can't access %s\0A\00"
@.str.1 = [24 x i8] c"chmod: can't change %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 3
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 (...) @Usage()
br label %13
13: ; preds = %11, %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 (i8*, ...) bitcast (i32 (...)* @oatoi to i32 (i8*, ...)*)(i8* %16)
store i32 %17, i32* %8
store i32 2, i32* %6
br label %18
18: ; preds = %59, %13
%19 = load i32, i32* %6
%20 = load i32, i32* %4
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %62
22: ; preds = %18
%23 = load i8**, i8*** %5
%24 = load i32, i32* %6
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8*, i8** %23, i64 %25
%27 = load i8*, i8** %26
%28 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @access to i32 (i8*, i32, ...)*)(i8* %27, i32 0)
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %39
30: ; preds = %22
%31 = load i8**, i8*** %5
%32 = load i32, i32* %6
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8*, i8** %31, i64 %33
%35 = load i8*, i8** %34
%36 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @prints to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %35)
%37 = load i32, i32* %7
%38 = add nsw i32 %37, 1
store i32 %38, i32* %7
br label %58
39: ; preds = %22
%40 = load i8**, i8*** %5
%41 = load i32, i32* %6
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8*, i8** %40, i64 %42
%44 = load i8*, i8** %43
%45 = load i32, i32* %8
%46 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @chmod to i32 (i8*, i32, ...)*)(i8* %44, i32 %45)
%47 = icmp slt i32 %46, 0
br i1 %47, label %48, label %57
48: ; preds = %39
%49 = load i8**, i8*** %5
%50 = load i32, i32* %6
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8*, i8** %49, i64 %51
%53 = load i8*, i8** %52
%54 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @prints to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %53)
%55 = load i32, i32* %7
%56 = add nsw i32 %55, 1
store i32 %56, i32* %7
br label %57
57: ; preds = %48, %39
br label %58
58: ; preds = %57, %30
br label %59
59: ; preds = %58
%60 = load i32, i32* %6
%61 = add nsw i32 %60, 1
store i32 %61, i32* %6
br label %18
62: ; preds = %18
%63 = load i32, i32* %7
unreachable
}

LLVM IR (-O2):
@.str = [24 x i8] c"chmod: can't access %s\0A\00"
@.str.1 = [24 x i8] c"chmod: can't change %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = tail call i32 (...) @Usage()
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = tail call i32 (i8*, ...) bitcast (i32 (...)* @oatoi to i32 (i8*, ...)*)(i8* %7)
br label %36
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32 (i8*, ...) bitcast (i32 (...)* @oatoi to i32 (i8*, ...)*)(i8* %11)
%13 = zext i32 %0 to i64
br label %14
14: ; preds = %9, %32
%15 = phi i64 [ 2, %9 ], [ %34, %32 ]
%16 = phi i32 [ 0, %9 ], [ %33, %32 ]
%17 = getelementptr inbounds i8*, i8** %1, i64 %15
%18 = load i8*, i8** %17
%19 = tail call i32 (i8*, i32, ...) bitcast (i32 (...)* @access to i32 (i8*, i32, ...)*)(i8* %18, i32 0)
%20 = icmp eq i32 %19, 0
%21 = load i8*, i8** %17
br i1 %20, label %25, label %22
22: ; preds = %14
%23 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @prints to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %21)
%24 = add nsw i32 %16, 1
br label %32
25: ; preds = %14
%26 = tail call i32 (i8*, i32, ...) bitcast (i32 (...)* @chmod to i32 (i8*, i32, ...)*)(i8* %21, i32 %12)
%27 = icmp slt i32 %26, 0
br i1 %27, label %28, label %32
28: ; preds = %25
%29 = load i8*, i8** %17
%30 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @prints to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %29)
%31 = add nsw i32 %16, 1
br label %32
32: ; preds = %22, %28, %25
%33 = phi i32 [ %24, %22 ], [ %31, %28 ], [ %16, %25 ]
%34 = add nuw nsw i64 %15, 1
%35 = icmp eq i64 %34, %13
br i1 %35, label %36, label %14
36: ; preds = %32, %4
%37 = phi i32 [ 0, %4 ], [ %33, %32 ]
tail call void @exit(i32 %37)
unreachable
}