#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 scalar_t__ uint32_t;

/* Variables and functions */
char *libgieditor_get_desc(scalar_t__);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sscanf(char *, char *, scalar_t__ *);
int main(int argc, char **argv) {
  uint32_t sysex_addr;
  if (argc != 2)
    return 1;
  sscanf(argv[1], "0x%x", &sysex_addr);
  const char *desc = libgieditor_get_desc(sysex_addr + 402653184);
  if (!desc) {
    printf("Address not found\n");
    return 1;
  }
  printf("%s\n", desc);
  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   $0x2,-0x8(%rbp)
je     115c <main+0x2c>
movl   $0x1,-0x4(%rbp)
jmp    11c6 <main+0x96>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe95(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1040 <sscanf@plt>
mov    -0x18(%rbp),%rdi
add    $0x18000000,%rdi
call   1050 <libgieditor_get_desc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11ad <main+0x7d>
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11c6 <main+0x96>
mov    -0x20(%rbp),%rsi
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    $0x1,%ebx
cmp    $0x2,%edi
jne    1180 <main+0x50>
mov    0x8(%rsi),%rdi
lea    0xeb6(%rip),%rsi
lea    0x8(%rsp),%rdx
call   1040 <sscanf@plt>
mov    $0x18000000,%edi
add    0x8(%rsp),%rdi
call   1050 <libgieditor_get_desc@plt>
test   %rax,%rax
je     1174 <main+0x44>
mov    %rax,%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
jmp    1180 <main+0x50>
lea    0xe8a(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"0x%x\00"
@.str.1 = [19 x i8] c"Address not found\0A\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 2
br i1 %9, label %10, label %11
10: ; preds = %2
store i32 1, i32* %3
br label %26
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 ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %6)
%16 = load i64, i64* %6
%17 = add nsw i64 %16, 402653184
%18 = call i8* @libgieditor_get_desc(i64 %17)
store i8* %18, i8** %7
%19 = load i8*, i8** %7
%20 = icmp ne i8* %19, null
br i1 %20, label %23, label %21
21: ; preds = %11
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %26
23: ; preds = %11
%24 = load i8*, i8** %7
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %24)
store i32 0, i32* %3
br label %26
26: ; preds = %23, %21, %10
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
@.str = [5 x i8] c"0x%x\00"
@str = [18 x i8] c"Address not found\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to i8*
%5 = icmp eq i32 %0, 2
br i1 %5, label %6, label %18
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %3)
%10 = load i64, i64* %3
%11 = add nsw i64 %10, 402653184
%12 = call i8* @libgieditor_get_desc(i64 %11)
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %16
14: ; preds = %6
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
br label %18
16: ; preds = %6
%17 = call i32 @puts(i8* %12)
br label %18
18: ; preds = %14, %16, %2
%19 = phi i32 [ 1, %2 ], [ 0, %16 ], [ 1, %14 ]
ret i32 %19
}