#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 EOF;
int pipara_setup();
int /*<<< orphan*/ pipara_write(int);
int /*<<< orphan*/ printf(char *, ...);
int sscanf(char *, char *, int *);
int /*<<< orphan*/ usage();
int main(int argc, char *argv[]) {
  if (argc <= 1) {
    usage();
    return 1;
  }
  int data;
  int count = sscanf(argv[1], "%X", &data);
  if (count < 1 || count == EOF) {
    printf("Invalid argument: %s\n", argv[1]);
    return 2;
  }
  printf("Output value: %02X (%d)\n", data, data);
  int rc = pipara_setup();
  if (rc != 0) {
    printf("pipara_setup() returned %d\n", rc);
  }
  pipara_write(data);
  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   $0x1,-0x8(%rbp)
jg     1183 <main+0x33>
mov    $0x0,%al
call   1070 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    1224 <main+0xd4>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe6e(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1060 <sscanf@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x1,-0x18(%rbp)
jl     11ba <main+0x6a>
mov    -0x18(%rbp),%eax
mov    0x2e36(%rip),%rcx
cmp    (%rcx),%eax
jne    11dc <main+0x8c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    1224 <main+0xd4>
mov    -0x14(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <pipara_setup@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1215 <main+0xc5>
mov    -0x1c(%rbp),%esi
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%edi
call   1050 <pipara_write@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
cmp    $0x1,%edi
jg     1168 <main+0x18>
xor    %eax,%eax
call   1070 <usage@plt>
mov    $0x1,%ebx
jmp    11e2 <main+0x92>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe8a(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1060 <sscanf@plt>
test   %eax,%eax
jle    11cb <main+0x7b>
mov    0x2e5d(%rip),%rcx
cmp    (%rcx),%eax
je     11cb <main+0x7b>
mov    0xc(%rsp),%edx
lea    0xe7f(%rip),%rdi
xor    %ebx,%ebx
mov    %edx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1030 <pipara_setup@plt>
test   %eax,%eax
je     11c0 <main+0x70>
lea    0xe7b(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%edi
call   1050 <pipara_write@plt>
jmp    11e2 <main+0x92>
mov    0x8(%rbx),%rsi
lea    0xe2d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x2,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%X\00"
@EOF = global i32 0
@.str.1 = [22 x i8] c"Invalid argument: %s\0A\00"
@.str.2 = [25 x i8] c"Output value: %02X (%d)\0A\00"
@.str.3 = [28 x i8] c"pipara_setup() returned %d\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 sle i32 %9, 1
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 (...) @usage()
store i32 1, i32* %3
br label %42
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @sscanf(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
store i32 %17, i32* %7
%18 = load i32, i32* %7
%19 = icmp slt i32 %18, 1
br i1 %19, label %24, label %20
20: ; preds = %13
%21 = load i32, i32* %7
%22 = load i32, i32* @EOF
%23 = icmp eq i32 %21, %22
br i1 %23, label %24, label %29
24: ; preds = %20, %13
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %27)
store i32 2, i32* %3
br label %42
29: ; preds = %20
%30 = load i32, i32* %6
%31 = load i32, i32* %6
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %30, i32 %31)
%33 = call i32 (...) @pipara_setup()
store i32 %33, i32* %8
%34 = load i32, i32* %8
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %29
%37 = load i32, i32* %8
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %37)
br label %39
39: ; preds = %36, %29
%40 = load i32, i32* %6
%41 = call i32 @pipara_write(i32 %40)
store i32 0, i32* %3
br label %42
42: ; preds = %39, %24, %11
%43 = load i32, i32* %3
ret i32 %43
}

LLVM IR (-O2):
@.str = [3 x i8] c"%X\00"
@EOF = global i32 0
@.str.1 = [22 x i8] c"Invalid argument: %s\0A\00"
@.str.2 = [25 x i8] c"Output value: %02X (%d)\0A\00"
@.str.3 = [28 x i8] c"pipara_setup() returned %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = icmp slt i32 %0, 2
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 (...) @usage()
br label %31
7: ; preds = %2
%8 = bitcast i32* %3 to i8*
%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 slt i32 %11, 1
%13 = load i32, i32* @EOF
%14 = icmp eq i32 %11, %13
%15 = select i1 %12, i1 true, i1 %14
br i1 %15, label %16, label %19
16: ; preds = %7
%17 = load i8*, i8** %9
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %17)
br label %29
19: ; preds = %7
%20 = load i32, i32* %3
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %20, i32 %20)
%22 = call i32 (...) @pipara_setup()
%23 = icmp eq i32 %22, 0
br i1 %23, label %26, label %24
24: ; preds = %19
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %22)
br label %26
26: ; preds = %24, %19
%27 = load i32, i32* %3
%28 = call i32 @pipara_write(i32 %27)
br label %29
29: ; preds = %26, %16
%30 = phi i32 [ 2, %16 ], [ 0, %26 ]
br label %31
31: ; preds = %29, %5
%32 = phi i32 [ 1, %5 ], [ %30, %29 ]
ret i32 %32
}