#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, size_t);
int /*<<< orphan*/ sscanf(char *, char *, size_t *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ vsd_deinit();
int vsd_get_size(size_t *);
scalar_t__ vsd_init();
int vsd_set_size(size_t);
int main(int argc, char **argv) {
  if (argc < 2) {
    fprintf(stderr, "Supply command name (size_set|size_get)\n");
    return EXIT_FAILURE;
  }
  if (vsd_init()) {
    perror("Couldn't init vsd device\n");
    return EXIT_FAILURE;
  }
  if (!strcmp(argv[1], "size_get")) {
    size_t size = 0;
    int ret = vsd_get_size(&size);
    if (!ret)
      printf("Size is %zu\n", size);
    else
      fprintf(stderr, "Couldn't get vsd size error code: %d\n", ret);
  } else if (!strcmp(argv[1], "size_set")) {
    if (argc > 2) {
      size_t size = 0;
      sscanf(argv[2], "%zu", &size);
      int ret = vsd_set_size(size);
      if (ret) {
        fprintf(stderr, "Couldn't set vsd size error code: %d\n", ret);
      }
    } else {
      fprintf(stderr, "Supply new size\n");
    }
  } else {
    fprintf(stderr, "Invalid command\n");
  }
  vsd_deinit();
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11d8 <main+0x48>
mov    0x2e29(%rip),%rax
mov    (%rax),%edi
lea    0xe40(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2e0a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    133c <main+0x1ac>
mov    $0x0,%al
call   1070 <vsd_init@plt>
cmp    $0x0,%rax
je     1206 <main+0x76>
lea    0xe39(%rip),%rdi
call   10a0 <perror@plt>
mov    0x2ddc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    133c <main+0x1ac>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe2e(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1275 <main+0xe5>
movq   $0x0,-0x18(%rbp)
lea    -0x18(%rbp),%rdi
call   1080 <vsd_get_size@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    1256 <main+0xc6>
mov    -0x18(%rbp),%rsi
lea    0xe00(%rip),%rdi
call   1040 <printf@plt>
jmp    1270 <main+0xe0>
mov    0x2d83(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%edx
lea    0xdf0(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    1329 <main+0x199>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdfb(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    130d <main+0x17d>
cmpl   $0x2,-0x8(%rbp)
jle    12f1 <main+0x161>
movq   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xdd5(%rip),%rsi
lea    -0x28(%rbp),%rdx
call   1090 <sscanf@plt>
mov    -0x28(%rbp),%rdi
call   10b0 <vsd_set_size@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     12ec <main+0x15c>
mov    0x2d07(%rip),%rax
mov    (%rax),%edi
mov    -0x2c(%rbp),%edx
lea    0xda7(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    1308 <main+0x178>
mov    0x2ce8(%rip),%rax
mov    (%rax),%edi
lea    0xdb1(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    1324 <main+0x194>
mov    0x2ccc(%rip),%rax
mov    (%rax),%edi
lea    0xda6(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    1329 <main+0x199>
mov    $0x0,%al
call   1030 <vsd_deinit@plt>
mov    0x2c99(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
cmp    $0x1,%edi
jg     11c0 <main+0x30>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
lea    0xe53(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x2e1d(%rip),%rax
jmp    12c1 <main+0x131>
mov    %rsi,%r14
mov    %edi,%ebp
xor    %eax,%eax
call   1070 <vsd_init@plt>
test   %rax,%rax
jne    12cc <main+0x13c>
mov    0x8(%r14),%rbx
lea    0xe63(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1214 <main+0x84>
lea    0xe8c(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     123d <main+0xad>
mov    0x2dda(%rip),%rax
mov    (%rax),%edi
lea    0xeb4(%rip),%rsi
jmp    12ac <main+0x11c>
movq   $0x0,0x8(%rsp)
lea    0x8(%rsp),%rdi
call   1080 <vsd_get_size@plt>
test   %eax,%eax
je     1289 <main+0xf9>
mov    0x2dae(%rip),%rcx
mov    (%rcx),%edi
lea    0xe1e(%rip),%rsi
jmp    127e <main+0xee>
cmp    $0x3,%ebp
jb     129c <main+0x10c>
movq   $0x0,0x8(%rsp)
mov    0x10(%r14),%rdi
lea    0xe32(%rip),%rsi
lea    0x8(%rsp),%rdx
call   1090 <sscanf@plt>
mov    0x8(%rsp),%rdi
call   10b0 <vsd_set_size@plt>
test   %eax,%eax
je     12b3 <main+0x123>
mov    0x2d6b(%rip),%rcx
mov    (%rcx),%edi
lea    0xe0e(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    12b3 <main+0x123>
mov    0x8(%rsp),%rsi
lea    0xdb7(%rip),%rdi
call   1040 <printf@plt>
jmp    12b3 <main+0x123>
mov    0x2d3d(%rip),%rax
mov    (%rax),%edi
lea    0xe06(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
xor    %eax,%eax
call   1030 <vsd_deinit@plt>
mov    0x2d0f(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xd56(%rip),%rdi
call   10a0 <perror@plt>
mov    0x2cf9(%rip),%rax
jmp    12c1 <main+0x131>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [41 x i8] c"Supply command name (size_set|size_get)\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [26 x i8] c"Couldn't init vsd device\0A\00"
@.str.2 = [9 x i8] c"size_get\00"
@.str.3 = [13 x i8] c"Size is %zu\0A\00"
@.str.4 = [38 x i8] c"Couldn't get vsd size error code: %d\0A\00"
@.str.5 = [9 x i8] c"size_set\00"
@.str.6 = [4 x i8] c"%zu\00"
@.str.7 = [38 x i8] c"Couldn't set vsd size error code: %d\0A\00"
@.str.8 = [17 x i8] c"Supply new size\0A\00"
@.str.9 = [17 x i8] c"Invalid command\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 i64
%7 = alloca i32
%8 = alloca i64
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 2
br i1 %11, label %12, label %16
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%15 = load i32, i32* @EXIT_FAILURE
store i32 %15, i32* %3
br label %74
16: ; preds = %2
%17 = call i64 (...) @vsd_init()
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%21 = load i32, i32* @EXIT_FAILURE
store i32 %21, i32* %3
br label %74
22: ; preds = %16
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i32 @strcmp(i8* %25, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%27 = icmp ne i32 %26, 0
br i1 %27, label %40, label %28
28: ; preds = %22
store i64 0, i64* %6
%29 = call i32 @vsd_get_size(i64* %6)
store i32 %29, i32* %7
%30 = load i32, i32* %7
%31 = icmp ne i32 %30, 0
br i1 %31, label %35, label %32
32: ; preds = %28
%33 = load i64, i64* %6
%34 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i64 %33)
br label %39
35: ; preds = %28
%36 = load i32, i32* @stderr
%37 = load i32, i32* %7
%38 = call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0), i32 %37)
br label %39
39: ; preds = %35, %32
br label %71
40: ; preds = %22
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 1
%43 = load i8*, i8** %42
%44 = call i32 @strcmp(i8* %43, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%45 = icmp ne i32 %44, 0
br i1 %45, label %67, label %46
46: ; preds = %40
%47 = load i32, i32* %4
%48 = icmp sgt i32 %47, 2
br i1 %48, label %49, label %63
49: ; preds = %46
store i64 0, i64* %8
%50 = load i8**, i8*** %5
%51 = getelementptr inbounds i8*, i8** %50, i64 2
%52 = load i8*, i8** %51
%53 = call i32 @sscanf(i8* %52, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i64* %8)
%54 = load i64, i64* %8
%55 = call i32 @vsd_set_size(i64 %54)
store i32 %55, i32* %9
%56 = load i32, i32* %9
%57 = icmp ne i32 %56, 0
br i1 %57, label %58, label %62
58: ; preds = %49
%59 = load i32, i32* @stderr
%60 = load i32, i32* %9
%61 = call i32 (i32, i8*, ...) @fprintf(i32 %59, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.7, i64 0, i64 0), i32 %60)
br label %62
62: ; preds = %58, %49
br label %66
63: ; preds = %46
%64 = load i32, i32* @stderr
%65 = call i32 (i32, i8*, ...) @fprintf(i32 %64, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0))
br label %66
66: ; preds = %63, %62
br label %70
67: ; preds = %40
%68 = load i32, i32* @stderr
%69 = call i32 (i32, i8*, ...) @fprintf(i32 %68, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0))
br label %70
70: ; preds = %67, %66
br label %71
71: ; preds = %70, %39
%72 = call i32 (...) @vsd_deinit()
%73 = load i32, i32* @EXIT_SUCCESS
store i32 %73, i32* %3
br label %74
74: ; preds = %71, %19, %12
%75 = load i32, i32* %3
ret i32 %75
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [41 x i8] c"Supply command name (size_set|size_get)\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [26 x i8] c"Couldn't init vsd device\0A\00"
@.str.2 = [9 x i8] c"size_get\00"
@.str.3 = [13 x i8] c"Size is %zu\0A\00"
@.str.4 = [38 x i8] c"Couldn't get vsd size error code: %d\0A\00"
@.str.5 = [9 x i8] c"size_set\00"
@.str.6 = [4 x i8] c"%zu\00"
@.str.7 = [38 x i8] c"Couldn't set vsd size error code: %d\0A\00"
@.str.8 = [17 x i8] c"Supply new size\0A\00"
@.str.9 = [17 x i8] c"Invalid command\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i64
%4 = alloca i64
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
br label %55
9: ; preds = %2
%10 = tail call i64 (...) @vsd_init()
%11 = icmp eq i64 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = tail call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
br label %55
14: ; preds = %9
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = tail call i32 @strcmp(i8* dereferenceable(1) %16, i8* dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %30
19: ; preds = %14
%20 = bitcast i64* %3 to i8*
store i64 0, i64* %3
%21 = call i32 @vsd_get_size(i64* %3)
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %19
%24 = load i64, i64* %3
%25 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i64 %24)
br label %29
26: ; preds = %19
%27 = load i32, i32* @stderr
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0), i32 %21)
br label %29
29: ; preds = %26, %23
br label %53
30: ; preds = %14
%31 = tail call i32 @strcmp(i8* dereferenceable(1) %16, i8* dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %50
33: ; preds = %30
%34 = icmp ugt i32 %0, 2
br i1 %34, label %35, label %47
35: ; preds = %33
%36 = bitcast i64* %4 to i8*
store i64 0, i64* %4
%37 = getelementptr inbounds i8*, i8** %1, i64 2
%38 = load i8*, i8** %37
%39 = call i32 @sscanf(i8* %38, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i64* %4)
%40 = load i64, i64* %4
%41 = call i32 @vsd_set_size(i64 %40)
%42 = icmp eq i32 %41, 0
br i1 %42, label %46, label %43
43: ; preds = %35
%44 = load i32, i32* @stderr
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.7, i64 0, i64 0), i32 %41)
br label %46
46: ; preds = %43, %35
br label %53
47: ; preds = %33
%48 = load i32, i32* @stderr
%49 = tail call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0))
br label %53
50: ; preds = %30
%51 = load i32, i32* @stderr
%52 = tail call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0))
br label %53
53: ; preds = %50, %47, %46, %29
%54 = call i32 (...) @vsd_deinit()
br label %55
55: ; preds = %53, %12, %6
%56 = phi i32* [ @EXIT_FAILURE, %6 ], [ @EXIT_FAILURE, %12 ], [ @EXIT_SUCCESS, %53 ]
%57 = load i32, i32* %56
ret i32 %57
}