#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 */
scalar_t__ chmod(char *, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
int strtol(char *, int /*<<< orphan*/ *, int);
int main(int argc, char *argv[]) {
  int mode;
  int i;
  if (argc < 2) {
    fprintf(stderr, "no mode given\n");
    exit(1);
  }
  mode = strtol(argv[1], NULL, 8);
  for (i = 2; i < argc; i++) {
    if (chmod(argv[i], mode) < 0) {
      perror(argv[i]);
    }
  }
  exit(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)
jge    118f <main+0x3f>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
lea    0xe80(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x8,%edx
call   1040 <strtol@plt>
mov    %eax,-0x14(%rbp)
movl   $0x2,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11fd <main+0xad>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x14(%rbp),%esi
call   1050 <chmod@plt>
cmp    $0x0,%rax
jge    11ea <main+0x9a>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1060 <perror@plt>
jmp    11ef <main+0x9f>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11af <main+0x5f>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
cmp    $0x1,%edi
jg     117c <main+0x2c>
mov    0x2e7c(%rip),%rax
mov    (%rax),%edi
lea    0xe93(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    %rsi,%r15
mov    %edi,%r14d
mov    0x8(%rsi),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <strtol@plt>
cmp    $0x2,%r14d
jne    119f <main+0x4f>
xor    %edi,%edi
call   1070 <exit@plt>
mov    %eax,%r12d
mov    %r14d,%ebx
mov    $0x2,%ebp
jmp    11b9 <main+0x69>
nopl   0x0(%rax)
add    $0x1,%rbp
cmp    %rbp,%rbx
je     1198 <main+0x48>
mov    (%r15,%rbp,8),%rdi
mov    %r12d,%esi
call   1050 <chmod@plt>
test   %rax,%rax
jns    11b0 <main+0x60>
mov    (%r15,%rbp,8),%rdi
call   1060 <perror@plt>
jmp    11b0 <main+0x60>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [15 x i8] c"no mode given\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 slt i32 %8, 2
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @strtol(i8* %17, i32* null, i32 8)
store i32 %18, i32* %6
store i32 2, i32* %7
br label %19
19: ; preds = %40, %14
%20 = load i32, i32* %7
%21 = load i32, i32* %4
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %43
23: ; preds = %19
%24 = load i8**, i8*** %5
%25 = load i32, i32* %7
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8*, i8** %24, i64 %26
%28 = load i8*, i8** %27
%29 = load i32, i32* %6
%30 = call i64 @chmod(i8* %28, i32 %29)
%31 = icmp slt i64 %30, 0
br i1 %31, label %32, label %39
32: ; preds = %23
%33 = load i8**, i8*** %5
%34 = load i32, i32* %7
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8*, i8** %33, i64 %35
%37 = load i8*, i8** %36
%38 = call i32 @perror(i8* %37)
br label %39
39: ; preds = %32, %23
br label %40
40: ; preds = %39
%41 = load i32, i32* %7
%42 = add nsw i32 %41, 1
store i32 %42, i32* %7
br label %19
43: ; preds = %19
%44 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [15 x i8] c"no mode given\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @strtol(i8* nocapture %10, i32* null, i32 8)
%12 = icmp eq i32 %0, 2
br i1 %12, label %27, label %13
13: ; preds = %8
%14 = zext i32 %0 to i64
br label %15
15: ; preds = %13, %24
%16 = phi i64 [ 2, %13 ], [ %25, %24 ]
%17 = getelementptr inbounds i8*, i8** %1, i64 %16
%18 = load i8*, i8** %17
%19 = tail call i64 @chmod(i8* %18, i32 %11)
%20 = icmp slt i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %15
%22 = load i8*, i8** %17
%23 = tail call i32 @perror(i8* %22)
br label %24
24: ; preds = %15, %21
%25 = add nuw nsw i64 %16, 1
%26 = icmp eq i64 %25, %14
br i1 %26, label %27, label %15
27: ; preds = %24, %8
%28 = tail call i32 @exit(i32 0)
unreachable
}