#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 int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, int);
int /*<<< orphan*/ printf(char *, ...);
int sscanf(char *, char *, int *, int *);
scalar_t__ strcmp(char *, char *);
int main(int argc, char **argv) {
  if (argc < 3) {
    printf("nothing to be done\r\n");
    return -1;
  }
  FILE *f = NULL;
  if (strcmp(argv[1], "u") == 0) {
    f = fopen("/sys/bus/usb/drivers/usb/unbind", "w");
  } else if (strcmp(argv[1], "b") == 0) {
    f = fopen("/sys/bus/usb/drivers/usb/bind", "w");
  } else {
    printf("unknown command %s\r\n", argv[1]);
    return -1;
  }
  if (f == NULL) {
    printf("i/o error\r\n");
    return -1;
  }
  int first;
  int second;
  if (sscanf(argv[2], "%i-%i", &first, &second) == 2) {
    fprintf(f, "%i-%i", first, second);
    printf("%i-%i\r\n", first, second);
  }
  fclose(f);
  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)
jge    119a <main+0x3a>
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12c1 <main+0x161>
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe64(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11dc <main+0x7c>
lea    0xe50(%rip),%rdi
lea    0xe69(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
jmp    123d <main+0xdd>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe4e(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1216 <main+0xb6>
lea    0xe3a(%rip),%rdi
lea    0xe2f(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
jmp    1238 <main+0xd8>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12c1 <main+0x161>
jmp    123d <main+0xdd>
cmpq   $0x0,-0x18(%rbp)
jne    1262 <main+0x102>
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12c1 <main+0x161>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe09(%rip),%rsi
lea    -0x1c(%rbp),%rdx
lea    -0x20(%rbp),%rcx
call   1070 <sscanf@plt>
cmp    $0x2,%eax
jne    12b1 <main+0x151>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
lea    0xde2(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
lea    0xdd6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
cmp    $0x2,%edi
jg     118f <main+0x1f>
lea    0xef2(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
jmp    124b <main+0xdb>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe63(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11d5 <main+0x65>
mov    0x8(%rbx),%rdi
lea    0xe72(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11de <main+0x6e>
mov    0x8(%rbx),%rsi
lea    0xe7d(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xffffffff,%eax
jmp    124b <main+0xdb>
lea    0xe26(%rip),%rdi
jmp    11e5 <main+0x75>
lea    0xe41(%rip),%rdi
lea    0xe36(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     1253 <main+0xe3>
mov    %rax,%r14
mov    0x10(%rbx),%rdi
lea    0xe55(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %rsp,%rcx
call   1080 <sscanf@plt>
cmp    $0x2,%eax
jne    1241 <main+0xd1>
mov    0x4(%rsp),%edx
mov    (%rsp),%ecx
lea    0xe35(%rip),%rsi
mov    %r14,%rdi
call   1070 <fprintf@plt>
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
lea    0xe25(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe0d(%rip),%rdi
jmp    1180 <main+0x10>

LLVM IR (-O0):
@.str = [21 x i8] c"nothing to be done\0D\0A\00"
@.str.1 = [2 x i8] c"u\00"
@.str.2 = [32 x i8] c"/sys/bus/usb/drivers/usb/unbind\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [2 x i8] c"b\00"
@.str.5 = [30 x i8] c"/sys/bus/usb/drivers/usb/bind\00"
@.str.6 = [21 x i8] c"unknown command %s\0D\0A\00"
@.str.7 = [12 x i8] c"i/o error\0D\0A\00"
@.str.8 = [6 x i8] c"%i-%i\00"
@.str.9 = [8 x i8] c"%i-%i\0D\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
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 3
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %57
13: ; preds = %2
store i32* null, i32** %6
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %13
%20 = call i32* @fopen(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %20, i32** %6
br label %35
21: ; preds = %13
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %21
%28 = call i32* @fopen(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %28, i32** %6
br label %34
29: ; preds = %21
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i8* %32)
store i32 -1, i32* %3
br label %57
34: ; preds = %27
br label %35
35: ; preds = %34, %19
%36 = load i32*, i32** %6
%37 = icmp eq i32* %36, null
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
store i32 -1, i32* %3
br label %57
40: ; preds = %35
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 2
%43 = load i8*, i8** %42
%44 = call i32 @sscanf(i8* %43, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i32* %7, i32* %8)
%45 = icmp eq i32 %44, 2
br i1 %45, label %46, label %54
46: ; preds = %40
%47 = load i32*, i32** %6
%48 = load i32, i32* %7
%49 = load i32, i32* %8
%50 = call i32 @fprintf(i32* %47, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i32 %48, i32 %49)
%51 = load i32, i32* %7
%52 = load i32, i32* %8
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0), i32 %51, i32 %52)
br label %54
54: ; preds = %46, %40
%55 = load i32*, i32** %6
%56 = call i32 @fclose(i32* %55)
store i32 0, i32* %3
br label %57
57: ; preds = %54, %38, %29, %11
%58 = load i32, i32* %3
ret i32 %58
}

LLVM IR (-O2):
@.str.1 = [2 x i8] c"u\00"
@.str.2 = [32 x i8] c"/sys/bus/usb/drivers/usb/unbind\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [2 x i8] c"b\00"
@.str.5 = [30 x i8] c"/sys/bus/usb/drivers/usb/bind\00"
@.str.6 = [21 x i8] c"unknown command %s\0D\0A\00"
@.str.8 = [6 x i8] c"%i-%i\00"
@.str.9 = [8 x i8] c"%i-%i\0D\0A\00"
@str = [11 x i8] c"i/o error\0D\00"
@str.10 = [20 x i8] c"nothing to be done\0D\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = icmp slt i32 %0, 3
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.10, i64 0, i64 0))
br label %42
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %20, label %13
13: ; preds = %8
%14 = load i8*, i8** %9
%15 = tail call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %13
%18 = load i8*, i8** %9
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i8* %18)
br label %42
20: ; preds = %13, %8
%21 = phi i8* [ getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), %8 ], [ getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), %13 ]
%22 = tail call i32* @fopen(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%23 = icmp eq i32* %22, null
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
br label %42
26: ; preds = %20
%27 = bitcast i32* %3 to i8*
%28 = bitcast i32* %4 to i8*
%29 = getelementptr inbounds i8*, i8** %1, i64 2
%30 = load i8*, i8** %29
%31 = call i32 @sscanf(i8* %30, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i32* %3, i32* %4)
%32 = icmp eq i32 %31, 2
br i1 %32, label %33, label %40
33: ; preds = %26
%34 = load i32, i32* %3
%35 = load i32, i32* %4
%36 = call i32 @fprintf(i32* %22, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i32 %34, i32 %35)
%37 = load i32, i32* %3
%38 = load i32, i32* %4
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0), i32 %37, i32 %38)
br label %40
40: ; preds = %33, %26
%41 = call i32 @fclose(i32* %22)
br label %42
42: ; preds = %17, %24, %40, %6
%43 = phi i32 [ -1, %6 ], [ -1, %24 ], [ 0, %40 ], [ -1, %17 ]
ret i32 %43
}