#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 /*<<< orphan*/ EXIT_FAILURE;
int EXIT_SUCCESS;
long INT_MAX;
int S_IRGRP;
int S_IROTH;
int S_IRUSR;
int S_IWGRP;
int S_IWOTH;
int S_IWUSR;
int _POSIX_PATH_MAX;
scalar_t__ chmod(char *, int);
int errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int snprintf(char *, int, char *, int, int);
int /*<<< orphan*/ stderr;
char *strerror(int);
long strtol(char *, char **, int);
int /*<<< orphan*/ usb_scan_devices(int *, int *);
int main(int argc, char **argv) {
  int bus, dev;
  int actual_bus = 0;
  int actual_dev = 0;
  char devname[_POSIX_PATH_MAX];
  long strtol_tmp1;
  char *strtol_tmp2;
  if (3 != argc) {
    fprintf(stderr, "usb_chmod: wrong number of arguments\n");
    fprintf(stderr, "         : usage, usb_chmod <bus> <dev>\n");
    exit(EXIT_FAILURE);
  }
  if (('\0' == argv[1][0]) || ('\0' == argv[2][0])) {
    fprintf(stderr, "usb_chmod: invalid arguments\n");
    exit(EXIT_FAILURE);
  }
  strtol_tmp1 = strtol(argv[1], &strtol_tmp2, 10);
  if ('\0' != *strtol_tmp2) {
    fprintf(stderr, "usbchmod: invalid first argument, not a number\n");
    exit(EXIT_FAILURE);
  }
  if (strtol_tmp1 > INT_MAX) {
    fprintf(stderr, "usbchmod: invalid first argument, number too large\n");
    exit(EXIT_FAILURE);
  }
  bus = (int)strtol_tmp1;
  strtol_tmp1 = strtol(argv[2], &strtol_tmp2, 10);
  if ('\0' != *strtol_tmp2) {
    fprintf(stderr, "usbchmod: invalid second argument, not a number\n");
    exit(EXIT_FAILURE);
  }
  if (strtol_tmp1 > INT_MAX) {
    fprintf(stderr, "usbchmod: invalid second argument, number too large\n");
    exit(EXIT_FAILURE);
  }
  dev = (int)strtol_tmp1;
  if (!usb_scan_devices(&actual_bus, &actual_dev)) {
    fprintf(stderr, "usb_chmod: failed to find eCos USB test application\n");
    exit(EXIT_FAILURE);
  }
  if ((bus != actual_bus) || (dev != actual_dev)) {
    fprintf(
        stderr,
        "usbchmod: mismatch between specified and actual USB identifiers.\n");
    fprintf(stderr,
            "         : eCos test application is at %03d/%03d, not %03d/%03d\n",
            actual_bus, actual_dev, bus, dev);
    exit(EXIT_FAILURE);
  }
  if (_POSIX_PATH_MAX == snprintf(devname, _POSIX_PATH_MAX,
                                  "/proc/bus/usb/"
                                  "%03d/%03d",
                                  actual_bus, actual_dev)) {
    fprintf(stderr, "usbchmod: internal error, buffer overflow\n");
    exit(EXIT_FAILURE);
  }
  if (0 != chmod(devname,
                 S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)) {
    int old_errno = errno;
    fprintf(stderr, "usbchmod: failed to modify access rights on %s\n",
            devname);
    fprintf(stderr, "         : %s\n", strerror(old_errno));
    exit(EXIT_FAILURE);
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    0x2e5d(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x50(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
mov    $0x3,%eax
cmp    -0x8(%rbp),%eax
je     120a <main+0x9a>
mov    0x2deb(%rip),%rax
mov    (%rax),%edi
lea    0xe22(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2dd4(%rip),%rax
mov    (%rax),%edi
lea    0xe31(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2d9d(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    %ecx,%eax
je     1234 <main+0xc4>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    %ecx,%eax
jne    1259 <main+0xe9>
mov    0x2d85(%rip),%rax
mov    (%rax),%edi
lea    0xe0b(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2d4e(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x40(%rbp),%rsi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %rax,-0x38(%rbp)
mov    -0x40(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    %ecx,%eax
je     12a9 <main+0x139>
mov    0x2d35(%rip),%rax
mov    (%rax),%edi
lea    0xdd9(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2cfe(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x38(%rbp),%rax
mov    0x2d2c(%rip),%rcx
cmp    (%rcx),%rax
jle    12e2 <main+0x172>
mov    0x2cfc(%rip),%rax
mov    (%rax),%edi
lea    0xdd0(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2cc5(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x38(%rbp),%rax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    -0x40(%rbp),%rsi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %rax,-0x38(%rbp)
mov    -0x40(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    %ecx,%eax
je     1339 <main+0x1c9>
mov    0x2ca5(%rip),%rax
mov    (%rax),%edi
lea    0xdad(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2c6e(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x38(%rbp),%rax
mov    0x2c9c(%rip),%rcx
cmp    (%rcx),%rax
jle    1372 <main+0x202>
mov    0x2c6c(%rip),%rax
mov    (%rax),%edi
lea    0xda5(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2c35(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x38(%rbp),%rax
mov    %eax,-0x18(%rbp)
lea    -0x1c(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <usb_scan_devices@plt>
cmp    $0x0,%eax
jne    13b4 <main+0x244>
mov    0x2c2a(%rip),%rax
mov    (%rax),%edi
lea    0xd98(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2bf3(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x14(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jne    13cc <main+0x25c>
mov    -0x18(%rbp),%eax
cmp    -0x20(%rbp),%eax
je     1416 <main+0x2a6>
mov    0x2bed(%rip),%rax
mov    (%rax),%edi
lea    0xd90(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2bd6(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
mov    -0x14(%rbp),%r8d
mov    -0x18(%rbp),%r9d
lea    0xdad(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2b91(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x50(%rbp),%rdi
mov    0x2bd7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x54(%rbp)
mov    0x2bcb(%rip),%rax
mov    (%rax),%esi
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
lea    0xdb2(%rip),%rdx
call   1040 <snprintf@plt>
mov    %eax,%ecx
mov    -0x54(%rbp),%eax
cmp    %ecx,%eax
jne    1474 <main+0x304>
mov    0x2b6a(%rip),%rax
mov    (%rax),%edi
lea    0xda8(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2b33(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x50(%rbp),%rdi
mov    0x2b19(%rip),%rax
mov    (%rax),%esi
mov    0x2b48(%rip),%rax
or     (%rax),%esi
mov    0x2b1f(%rip),%rax
or     (%rax),%esi
mov    0x2b3e(%rip),%rax
or     (%rax),%esi
mov    0x2b05(%rip),%rax
or     (%rax),%esi
mov    0x2ad4(%rip),%rax
or     (%rax),%esi
call   1070 <chmod@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     151e <main+0x3ae>
mov    -0x50(%rbp),%rdx
mov    0x2aec(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    0x2ae8(%rip),%rax
mov    (%rax),%edi
lea    0xd51(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2ad1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x58(%rbp)
mov    -0x44(%rbp),%edi
call   1090 <strerror@plt>
mov    -0x58(%rbp),%edi
mov    %rax,%rdx
lea    0xd59(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2a89(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    0x2a6b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsp,%r12
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    0x2e5f(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%r15
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
cmp    $0x3,%edi
jne    12fd <main+0x18d>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
cmpb   $0x0,(%rdi)
je     12e8 <main+0x178>
mov    0x10(%rbx),%rax
cmpb   $0x0,(%rax)
je     12e8 <main+0x178>
lea    -0x38(%rbp),%rsi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %rax,%r14
mov    -0x38(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1322 <main+0x1b2>
mov    %r12,-0x40(%rbp)
mov    0x2de5(%rip),%r13
cmp    0x0(%r13),%r14
jg     1337 <main+0x1c7>
mov    0x10(%rbx),%rdi
lea    -0x38(%rbp),%rsi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %rax,%r12
mov    -0x38(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1349 <main+0x1d9>
cmp    0x0(%r13),%r12
jg     135b <main+0x1eb>
lea    -0x30(%rbp),%rdi
lea    -0x2c(%rbp),%rsi
call   1030 <usb_scan_devices@plt>
test   %eax,%eax
je     136d <main+0x1fd>
cmp    %r14d,-0x30(%rbp)
jne    137f <main+0x20f>
cmp    %r12d,-0x2c(%rbp)
jne    137f <main+0x20f>
mov    0x2d97(%rip),%rax
mov    (%rax),%ebx
lea    0xf85(%rip),%rdx
mov    %r15,%rdi
mov    %ebx,%esi
mov    %r14d,%ecx
mov    %r12d,%r8d
call   1040 <snprintf@plt>
cmp    %eax,%ebx
je     13b4 <main+0x244>
mov    0x2d0f(%rip),%rax
mov    0x2d40(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2d15(%rip),%rax
or     (%rax),%esi
mov    0x2d34(%rip),%rax
or     (%rax),%esi
mov    0x2cfb(%rip),%rax
or     (%rax),%esi
mov    0x2cca(%rip),%rax
or     (%rax),%esi
mov    %r15,%rdi
call   1070 <chmod@plt>
test   %rax,%rax
mov    -0x40(%rbp),%rax
jne    13d9 <main+0x269>
mov    %rax,%rsp
mov    0x2cb9(%rip),%rax
mov    (%rax),%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2cd1(%rip),%rax
mov    (%rax),%edi
lea    0xd57(%rip),%rsi
jmp    13c4 <main+0x254>
mov    0x2cbc(%rip),%rbx
mov    (%rbx),%edi
lea    0xcf3(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%rbx),%edi
lea    0xd09(%rip),%rsi
jmp    13c4 <main+0x254>
mov    0x2c97(%rip),%rax
mov    (%rax),%edi
lea    0xd3b(%rip),%rsi
jmp    13c4 <main+0x254>
mov    0x2c82(%rip),%rax
mov    (%rax),%edi
lea    0xd56(%rip),%rsi
jmp    13c4 <main+0x254>
mov    0x2c70(%rip),%rax
mov    (%rax),%edi
lea    0xd78(%rip),%rsi
jmp    13c4 <main+0x254>
mov    0x2c5e(%rip),%rax
mov    (%rax),%edi
lea    0xd97(%rip),%rsi
jmp    13c4 <main+0x254>
mov    0x2c4c(%rip),%rax
mov    (%rax),%edi
lea    0xdba(%rip),%rsi
jmp    13c4 <main+0x254>
mov    0x2c3a(%rip),%rbx
mov    (%rbx),%edi
lea    0xddd(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%rbx),%edi
mov    -0x30(%rbp),%edx
mov    -0x2c(%rbp),%ecx
lea    0xe09(%rip),%rsi
mov    %r14d,%r8d
mov    %r12d,%r9d
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    13cb <main+0x25b>
mov    0x2c05(%rip),%rax
mov    (%rax),%edi
lea    0xe43(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x2bce(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    0x2bd8(%rip),%rax
mov    (%rax),%r14d
mov    0x2bd6(%rip),%rbx
mov    (%rbx),%edi
lea    0xe3f(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%rbx),%ebx
mov    %r14d,%edi
call   1090 <strerror@plt>
lea    0xe54(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    13cb <main+0x25b>

LLVM IR (-O0):
@_POSIX_PATH_MAX = global i32 0
@stderr = global i32 0
@.str = [38 x i8] c"usb_chmod: wrong number of arguments\0A\00"
@.str.1 = [41 x i8] c" : usage, usb_chmod <bus> <dev>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [30 x i8] c"usb_chmod: invalid arguments\0A\00"
@.str.3 = [48 x i8] c"usbchmod: invalid first argument, not a number\0A\00"
@INT_MAX = global i64 0
@.str.4 = [52 x i8] c"usbchmod: invalid first argument, number too large\0A\00"
@.str.5 = [49 x i8] c"usbchmod: invalid second argument, not a number\0A\00"
@.str.6 = [53 x i8] c"usbchmod: invalid second argument, number too large\0A\00"
@.str.7 = [53 x i8] c"usb_chmod: failed to find eCos USB test application\0A\00"
@.str.8 = [66 x i8] c"usbchmod: mismatch between specified and actual USB identifiers.\0A\00"
@.str.9 = [65 x i8] c" : eCos test application is at %03d/%03d, not %03d/%03d\0A\00"
@.str.10 = [24 x i8] c"/proc/bus/usb/%03d/%03d\00"
@.str.11 = [43 x i8] c"usbchmod: internal error, buffer overflow\0A\00"
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IRGRP = global i32 0
@S_IWGRP = global i32 0
@S_IROTH = global i32 0
@S_IWOTH = global i32 0
@errno = global i32 0
@.str.12 = [48 x i8] c"usbchmod: failed to modify access rights on %s\0A\00"
@.str.13 = [15 x i8] c" : %s\0A\00"
@EXIT_SUCCESS = global i32 0
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
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i64
%13 = alloca i8*
%14 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
store i32 0, i32* %9
%15 = load i32, i32* @_POSIX_PATH_MAX
%16 = zext i32 %15 to i64
%17 = call i8* @llvm.stacksave()
store i8* %17, i8** %10
%18 = alloca i8, i64 %16
store i64 %16, i64* %11
%19 = load i32, i32* %4
%20 = icmp ne i32 3, %19
br i1 %20, label %21, label %28
21: ; preds = %2
%22 = load i32, i32* @stderr
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%24 = load i32, i32* @stderr
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
%26 = load i32, i32* @EXIT_FAILURE
%27 = call i32 @exit(i32 %26)
unreachable
28: ; preds = %2
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = getelementptr inbounds i8, i8* %31, i64 0
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp eq i32 0, %34
br i1 %35, label %44, label %36
36: ; preds = %28
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 2
%39 = load i8*, i8** %38
%40 = getelementptr inbounds i8, i8* %39, i64 0
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = icmp eq i32 0, %42
br i1 %43, label %44, label %49
44: ; preds = %36, %28
%45 = load i32, i32* @stderr
%46 = call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%47 = load i32, i32* @EXIT_FAILURE
%48 = call i32 @exit(i32 %47)
unreachable
49: ; preds = %36
%50 = load i8**, i8*** %5
%51 = getelementptr inbounds i8*, i8** %50, i64 1
%52 = load i8*, i8** %51
%53 = call i64 @strtol(i8* %52, i8** %13, i32 10)
store i64 %53, i64* %12
%54 = load i8*, i8** %13
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = icmp ne i32 0, %56
br i1 %57, label %58, label %63
58: ; preds = %49
%59 = load i32, i32* @stderr
%60 = call i32 (i32, i8*, ...) @fprintf(i32 %59, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0))
%61 = load i32, i32* @EXIT_FAILURE
%62 = call i32 @exit(i32 %61)
unreachable
63: ; preds = %49
%64 = load i64, i64* %12
%65 = load i64, i64* @INT_MAX
%66 = icmp sgt i64 %64, %65
br i1 %66, label %67, label %72
67: ; preds = %63
%68 = load i32, i32* @stderr
%69 = call i32 (i32, i8*, ...) @fprintf(i32 %68, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.4, i64 0, i64 0))
%70 = load i32, i32* @EXIT_FAILURE
%71 = call i32 @exit(i32 %70)
unreachable
72: ; preds = %63
%73 = load i64, i64* %12
%74 = trunc i64 %73 to i32
store i32 %74, i32* %6
%75 = load i8**, i8*** %5
%76 = getelementptr inbounds i8*, i8** %75, i64 2
%77 = load i8*, i8** %76
%78 = call i64 @strtol(i8* %77, i8** %13, i32 10)
store i64 %78, i64* %12
%79 = load i8*, i8** %13
%80 = load i8, i8* %79
%81 = sext i8 %80 to i32
%82 = icmp ne i32 0, %81
br i1 %82, label %83, label %88
83: ; preds = %72
%84 = load i32, i32* @stderr
%85 = call i32 (i32, i8*, ...) @fprintf(i32 %84, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0))
%86 = load i32, i32* @EXIT_FAILURE
%87 = call i32 @exit(i32 %86)
unreachable
88: ; preds = %72
%89 = load i64, i64* %12
%90 = load i64, i64* @INT_MAX
%91 = icmp sgt i64 %89, %90
br i1 %91, label %92, label %97
92: ; preds = %88
%93 = load i32, i32* @stderr
%94 = call i32 (i32, i8*, ...) @fprintf(i32 %93, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.6, i64 0, i64 0))
%95 = load i32, i32* @EXIT_FAILURE
%96 = call i32 @exit(i32 %95)
unreachable
97: ; preds = %88
%98 = load i64, i64* %12
%99 = trunc i64 %98 to i32
store i32 %99, i32* %7
%100 = call i32 @usb_scan_devices(i32* %8, i32* %9)
%101 = icmp ne i32 %100, 0
br i1 %101, label %107, label %102
102: ; preds = %97
%103 = load i32, i32* @stderr
%104 = call i32 (i32, i8*, ...) @fprintf(i32 %103, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.7, i64 0, i64 0))
%105 = load i32, i32* @EXIT_FAILURE
%106 = call i32 @exit(i32 %105)
unreachable
107: ; preds = %97
%108 = load i32, i32* %6
%109 = load i32, i32* %8
%110 = icmp ne i32 %108, %109
br i1 %110, label %115, label %111
111: ; preds = %107
%112 = load i32, i32* %7
%113 = load i32, i32* %9
%114 = icmp ne i32 %112, %113
br i1 %114, label %115, label %126
115: ; preds = %111, %107
%116 = load i32, i32* @stderr
%117 = call i32 (i32, i8*, ...) @fprintf(i32 %116, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.8, i64 0, i64 0))
%118 = load i32, i32* @stderr
%119 = load i32, i32* %8
%120 = load i32, i32* %9
%121 = load i32, i32* %6
%122 = load i32, i32* %7
%123 = call i32 (i32, i8*, ...) @fprintf(i32 %118, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.9, i64 0, i64 0), i32 %119, i32 %120, i32 %121, i32 %122)
%124 = load i32, i32* @EXIT_FAILURE
%125 = call i32 @exit(i32 %124)
unreachable
126: ; preds = %111
%127 = load i32, i32* @_POSIX_PATH_MAX
%128 = load i32, i32* @_POSIX_PATH_MAX
%129 = load i32, i32* %8
%130 = load i32, i32* %9
%131 = call i32 @snprintf(i8* %18, i32 %128, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0), i32 %129, i32 %130)
%132 = icmp eq i32 %127, %131
br i1 %132, label %133, label %138
133: ; preds = %126
%134 = load i32, i32* @stderr
%135 = call i32 (i32, i8*, ...) @fprintf(i32 %134, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.11, i64 0, i64 0))
%136 = load i32, i32* @EXIT_FAILURE
%137 = call i32 @exit(i32 %136)
unreachable
138: ; preds = %126
%139 = load i32, i32* @S_IRUSR
%140 = load i32, i32* @S_IWUSR
%141 = or i32 %139, %140
%142 = load i32, i32* @S_IRGRP
%143 = or i32 %141, %142
%144 = load i32, i32* @S_IWGRP
%145 = or i32 %143, %144
%146 = load i32, i32* @S_IROTH
%147 = or i32 %145, %146
%148 = load i32, i32* @S_IWOTH
%149 = or i32 %147, %148
%150 = call i64 @chmod(i8* %18, i32 %149)
%151 = icmp ne i64 0, %150
br i1 %151, label %152, label %162
152: ; preds = %138
%153 = load i32, i32* @errno
store i32 %153, i32* %14
%154 = load i32, i32* @stderr
%155 = call i32 (i32, i8*, ...) @fprintf(i32 %154, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.12, i64 0, i64 0), i8* %18)
%156 = load i32, i32* @stderr
%157 = load i32, i32* %14
%158 = call i8* @strerror(i32 %157)
%159 = call i32 (i32, i8*, ...) @fprintf(i32 %156, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.13, i64 0, i64 0), i8* %158)
%160 = load i32, i32* @EXIT_FAILURE
%161 = call i32 @exit(i32 %160)
unreachable
162: ; preds = %138
%163 = load i32, i32* @EXIT_SUCCESS
store i32 %163, i32* %3
%164 = load i8*, i8** %10
%165 = load i32, i32* %3
ret i32 %165
}

LLVM IR (-O2):
@_POSIX_PATH_MAX = global i32 0
@stderr = global i32 0
@.str = [38 x i8] c"usb_chmod: wrong number of arguments\0A\00"
@.str.1 = [41 x i8] c" : usage, usb_chmod <bus> <dev>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [30 x i8] c"usb_chmod: invalid arguments\0A\00"
@.str.3 = [48 x i8] c"usbchmod: invalid first argument, not a number\0A\00"
@INT_MAX = global i64 0
@.str.4 = [52 x i8] c"usbchmod: invalid first argument, number too large\0A\00"
@.str.5 = [49 x i8] c"usbchmod: invalid second argument, not a number\0A\00"
@.str.6 = [53 x i8] c"usbchmod: invalid second argument, number too large\0A\00"
@.str.7 = [53 x i8] c"usb_chmod: failed to find eCos USB test application\0A\00"
@.str.8 = [66 x i8] c"usbchmod: mismatch between specified and actual USB identifiers.\0A\00"
@.str.9 = [65 x i8] c" : eCos test application is at %03d/%03d, not %03d/%03d\0A\00"
@.str.10 = [24 x i8] c"/proc/bus/usb/%03d/%03d\00"
@.str.11 = [43 x i8] c"usbchmod: internal error, buffer overflow\0A\00"
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IRGRP = global i32 0
@S_IWGRP = global i32 0
@S_IROTH = global i32 0
@S_IWOTH = global i32 0
@errno = global i32 0
@.str.12 = [48 x i8] c"usbchmod: failed to modify access rights on %s\0A\00"
@.str.13 = [15 x i8] c" : %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%7 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%8 = load i32, i32* @_POSIX_PATH_MAX
%9 = zext i32 %8 to i64
%10 = tail call i8* @llvm.stacksave()
%11 = alloca i8, i64 %9
%12 = bitcast i8** %5 to i8*
%13 = icmp eq i32 %0, 3
br i1 %13, label %21, label %14
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = tail call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%17 = load i32, i32* @stderr
%18 = tail call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
%19 = load i32, i32* @EXIT_FAILURE
%20 = tail call i32 @exit(i32 %19)
unreachable
21: ; preds = %2
%22 = getelementptr inbounds i8*, i8** %1, i64 1
%23 = load i8*, i8** %22
%24 = load i8, i8* %23
%25 = icmp eq i8 %24, 0
br i1 %25, label %31, label %26
26: ; preds = %21
%27 = getelementptr inbounds i8*, i8** %1, i64 2
%28 = load i8*, i8** %27
%29 = load i8, i8* %28
%30 = icmp eq i8 %29, 0
br i1 %30, label %31, label %36
31: ; preds = %26, %21
%32 = load i32, i32* @stderr
%33 = tail call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%34 = load i32, i32* @EXIT_FAILURE
%35 = tail call i32 @exit(i32 %34)
unreachable
36: ; preds = %26
%37 = call i64 @strtol(i8* %23, i8** %5, i32 10)
%38 = load i8*, i8** %5
%39 = load i8, i8* %38
%40 = icmp eq i8 %39, 0
br i1 %40, label %46, label %41
41: ; preds = %36
%42 = load i32, i32* @stderr
%43 = tail call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0))
%44 = load i32, i32* @EXIT_FAILURE
%45 = tail call i32 @exit(i32 %44)
unreachable
46: ; preds = %36
%47 = load i64, i64* @INT_MAX
%48 = icmp sgt i64 %37, %47
br i1 %48, label %49, label %54
49: ; preds = %46
%50 = load i32, i32* @stderr
%51 = tail call i32 (i32, i8*, ...) @fprintf(i32 %50, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.4, i64 0, i64 0))
%52 = load i32, i32* @EXIT_FAILURE
%53 = tail call i32 @exit(i32 %52)
unreachable
54: ; preds = %46
%55 = trunc i64 %37 to i32
%56 = load i8*, i8** %27
%57 = call i64 @strtol(i8* %56, i8** %5, i32 10)
%58 = load i8*, i8** %5
%59 = load i8, i8* %58
%60 = icmp eq i8 %59, 0
br i1 %60, label %66, label %61
61: ; preds = %54
%62 = load i32, i32* @stderr
%63 = tail call i32 (i32, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0))
%64 = load i32, i32* @EXIT_FAILURE
%65 = tail call i32 @exit(i32 %64)
unreachable
66: ; preds = %54
%67 = load i64, i64* @INT_MAX
%68 = icmp sgt i64 %57, %67
br i1 %68, label %69, label %74
69: ; preds = %66
%70 = load i32, i32* @stderr
%71 = tail call i32 (i32, i8*, ...) @fprintf(i32 %70, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.6, i64 0, i64 0))
%72 = load i32, i32* @EXIT_FAILURE
%73 = tail call i32 @exit(i32 %72)
unreachable
74: ; preds = %66
%75 = trunc i64 %57 to i32
%76 = call i32 @usb_scan_devices(i32* %3, i32* %4)
%77 = icmp eq i32 %76, 0
br i1 %77, label %78, label %83
78: ; preds = %74
%79 = load i32, i32* @stderr
%80 = call i32 (i32, i8*, ...) @fprintf(i32 %79, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.7, i64 0, i64 0))
%81 = load i32, i32* @EXIT_FAILURE
%82 = call i32 @exit(i32 %81)
unreachable
83: ; preds = %74
%84 = load i32, i32* %3
%85 = icmp eq i32 %84, %55
%86 = load i32, i32* %4
%87 = icmp eq i32 %86, %75
%88 = select i1 %85, i1 %87, i1 false
br i1 %88, label %98, label %89
89: ; preds = %83
%90 = load i32, i32* @stderr
%91 = call i32 (i32, i8*, ...) @fprintf(i32 %90, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.8, i64 0, i64 0))
%92 = load i32, i32* @stderr
%93 = load i32, i32* %3
%94 = load i32, i32* %4
%95 = call i32 (i32, i8*, ...) @fprintf(i32 %92, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.9, i64 0, i64 0), i32 %93, i32 %94, i32 %55, i32 %75)
%96 = load i32, i32* @EXIT_FAILURE
%97 = call i32 @exit(i32 %96)
unreachable
98: ; preds = %83
%99 = load i32, i32* @_POSIX_PATH_MAX
%100 = call i32 @snprintf(i8* %11, i32 %99, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0), i32 %55, i32 %75)
%101 = icmp eq i32 %99, %100
br i1 %101, label %102, label %107
102: ; preds = %98
%103 = load i32, i32* @stderr
%104 = call i32 (i32, i8*, ...) @fprintf(i32 %103, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.11, i64 0, i64 0))
%105 = load i32, i32* @EXIT_FAILURE
%106 = call i32 @exit(i32 %105)
unreachable
107: ; preds = %98
%108 = load i32, i32* @S_IRUSR
%109 = load i32, i32* @S_IWUSR
%110 = or i32 %109, %108
%111 = load i32, i32* @S_IRGRP
%112 = or i32 %110, %111
%113 = load i32, i32* @S_IWGRP
%114 = or i32 %112, %113
%115 = load i32, i32* @S_IROTH
%116 = or i32 %114, %115
%117 = load i32, i32* @S_IWOTH
%118 = or i32 %116, %117
%119 = call i64 @chmod(i8* %11, i32 %118)
%120 = icmp eq i64 %119, 0
br i1 %120, label %130, label %121
121: ; preds = %107
%122 = load i32, i32* @errno
%123 = load i32, i32* @stderr
%124 = call i32 (i32, i8*, ...) @fprintf(i32 %123, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.12, i64 0, i64 0), i8* %11)
%125 = load i32, i32* @stderr
%126 = call i8* @strerror(i32 %122)
%127 = call i32 (i32, i8*, ...) @fprintf(i32 %125, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.13, i64 0, i64 0), i8* %126)
%128 = load i32, i32* @EXIT_FAILURE
%129 = call i32 @exit(i32 %128)
unreachable
130: ; preds = %107
%131 = load i32, i32* @EXIT_SUCCESS
ret i32 %131
}