#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*/ close(int);
int get_fd();
int /*<<< orphan*/ printf(char *);
int set_ext_csd(int, unsigned int, unsigned int);
int /*<<< orphan*/ sscanf(char *, char *, unsigned int *);
int main(int argc, char **argv) {
  int ret = 0;
  int fd = 0;
  unsigned int offset = 0;
  unsigned int value = 0;
  if (argc != 3) {
    printf("Usage : write_ext_csd offset value\n");
    return 1;
  }
  sscanf(argv[1], "%u", &offset);
  sscanf(argv[2], "%u", &value);
  fd = get_fd();
  if (fd >= 0) {
    ret = set_ext_csd(fd, offset, value);
    close(fd);
  }
  return ret;
}


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)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11a4 <main+0x54>
lea    0xe6d(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1207 <main+0xb7>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe71(%rip),%rsi
lea    -0x1c(%rbp),%rdx
call   1050 <sscanf@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe59(%rip),%rsi
lea    -0x20(%rbp),%rdx
call   1050 <sscanf@plt>
mov    $0x0,%al
call   1070 <get_fd@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jl     1201 <main+0xb1>
mov    -0x18(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1060 <set_ext_csd@plt>
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%edi
call   1040 <close@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
movl   $0x0,(%rsp)
cmp    $0x3,%edi
jne    11b9 <main+0x69>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe8b(%rip),%rbp
lea    0x4(%rsp),%rdx
mov    %rbp,%rsi
call   1050 <sscanf@plt>
mov    0x10(%rbx),%rdi
mov    %rsp,%rdx
mov    %rbp,%rsi
call   1050 <sscanf@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1070 <get_fd@plt>
test   %eax,%eax
js     11ca <main+0x7a>
mov    %eax,%ebp
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
mov    %eax,%edi
call   1060 <set_ext_csd@plt>
mov    %eax,%ebx
mov    %ebp,%edi
call   1040 <close@plt>
jmp    11ca <main+0x7a>
lea    0xe43(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [36 x i8] c"Usage : write_ext_csd offset value\0A\00"
@.str.1 = [3 x i8] c"%u\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
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 3
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %35
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @sscanf(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 2
%21 = load i8*, i8** %20
%22 = call i32 @sscanf(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %9)
%23 = call i32 (...) @get_fd()
store i32 %23, i32* %7
%24 = load i32, i32* %7
%25 = icmp sge i32 %24, 0
br i1 %25, label %26, label %33
26: ; preds = %14
%27 = load i32, i32* %7
%28 = load i32, i32* %8
%29 = load i32, i32* %9
%30 = call i32 @set_ext_csd(i32 %27, i32 %28, i32 %29)
store i32 %30, i32* %6
%31 = load i32, i32* %7
%32 = call i32 @close(i32 %31)
br label %33
33: ; preds = %26, %14
%34 = load i32, i32* %6
store i32 %34, i32* %3
br label %35
35: ; preds = %33, %12
%36 = load i32, i32* %3
ret i32 %36
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%u\00"
@str = [35 x i8] c"Usage : write_ext_csd offset value\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%6 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%7 = icmp eq i32 %0, 3
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
br label %24
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = call i32 @sscanf(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%14 = getelementptr inbounds i8*, i8** %1, i64 2
%15 = load i8*, i8** %14
%16 = call i32 @sscanf(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%17 = call i32 (...) @get_fd()
%18 = icmp sgt i32 %17, -1
br i1 %18, label %19, label %24
19: ; preds = %10
%20 = load i32, i32* %3
%21 = load i32, i32* %4
%22 = call i32 @set_ext_csd(i32 %17, i32 %20, i32 %21)
%23 = call i32 @close(i32 %17)
br label %24
24: ; preds = %10, %19, %8
%25 = phi i32 [ 1, %8 ], [ %22, %19 ], [ 0, %10 ]
ret i32 %25
}