#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__ ledctl(unsigned int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ print_usage();
int /*<<< orphan*/ printf(char *, char *);
int sscanf(char *, char *, unsigned int *);
int main(int argc, char **argv) {
  unsigned int mask;
  if (argc == 0) {
    print_usage();
    return 0;
  }
  if (sscanf(argv[1], "%x", &mask) != 1) {
    printf("Bad argument: %s\n", argv[1]);
    print_usage();
    return -1;
  }
  if (ledctl(mask) != 0) {
    perror("ERROR");
    return -1;
  }
  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   $0x0,-0x8(%rbp)
jne    1183 <main+0x33>
mov    $0x0,%al
call   1070 <print_usage@plt>
movl   $0x0,-0x4(%rbp)
jmp    11fc <main+0xac>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe6e(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1050 <sscanf@plt>
cmp    $0x1,%eax
je     11cb <main+0x7b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe50(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1070 <print_usage@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11fc <main+0xac>
mov    -0x14(%rbp),%edi
call   1040 <ledctl@plt>
cmp    $0x0,%rax
je     11f5 <main+0xa5>
lea    0xe31(%rip),%rdi
call   1060 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11fc <main+0xac>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
test   %edi,%edi
je     1194 <main+0x44>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe99(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1050 <sscanf@plt>
cmp    $0x1,%eax
jne    119f <main+0x4f>
mov    0xc(%rsp),%edi
call   1040 <ledctl@plt>
xor    %ebx,%ebx
test   %rax,%rax
je     11bb <main+0x6b>
lea    0xe88(%rip),%rdi
call   1060 <perror@plt>
jmp    11b6 <main+0x66>
xor    %ebx,%ebx
xor    %eax,%eax
call   1070 <print_usage@plt>
jmp    11bb <main+0x6b>
mov    0x8(%rbx),%rsi
lea    0xe59(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
call   1070 <print_usage@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%x\00"
@.str.1 = [18 x i8] c"Bad argument: %s\0A\00"
@.str.2 = [6 x i8] c"ERROR\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 (...) @print_usage()
store i32 0, i32* %3
br label %30
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @sscanf(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
%16 = icmp ne i32 %15, 1
br i1 %16, label %17, label %23
17: ; preds = %11
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = call i32 (...) @print_usage()
store i32 -1, i32* %3
br label %30
23: ; preds = %11
%24 = load i32, i32* %6
%25 = call i64 @ledctl(i32 %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %23
%28 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %3
br label %30
29: ; preds = %23
store i32 0, i32* %3
br label %30
30: ; preds = %29, %27, %17, %9
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
@.str = [3 x i8] c"%x\00"
@.str.1 = [18 x i8] c"Bad argument: %s\0A\00"
@.str.2 = [6 x i8] c"ERROR\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = icmp eq i32 %0, 0
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 (...) @print_usage()
br label %23
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = call i32 @sscanf(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%12 = icmp eq i32 %11, 1
br i1 %12, label %17, label %13
13: ; preds = %8
%14 = load i8*, i8** %9
%15 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = call i32 (...) @print_usage()
br label %23
17: ; preds = %8
%18 = load i32, i32* %3
%19 = call i64 @ledctl(i32 %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %23, label %21
21: ; preds = %17
%22 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %23
23: ; preds = %17, %21, %13, %6
%24 = phi i32 [ 0, %6 ], [ -1, %13 ], [ -1, %21 ], [ 0, %17 ]
ret i32 %24
}