#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int sscanf(char *, char *, float *);
int /*<<< orphan*/ stderr;
int processInput(int maxval, char **argv, int argc, int *data) {
  if (argc < 3) {
    fprintf(stderr, "error: you must provide a percentage\n");
    exit(1);
  }
  float inputval;
  if (sscanf(argv[2], "%f", &inputval) != 1) {
    fprintf(stderr,
            "error: please provide a percentage between 0.0 and 100, you gave: "
            "%s\n",
            argv[2]);
    exit(1);
  }
  if (inputval < 0 || inputval > 100) {
    fprintf(stderr,
            "error: please provide a percentage between 0.0 and 100, you gave: "
            "%F\n",
            inputval);
    exit(1);
  }
  *data = (((float)inputval / 100) * maxval);
  return 0;
}


x86 assembly (clang, -O0):
<processInput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
cmpl   $0x3,-0x14(%rbp)
jge    1171 <processInput+0x41>
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
lea    0xea4(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xeaa(%rip),%rsi
lea    -0x24(%rbp),%rdx
call   1040 <sscanf@plt>
cmp    $0x1,%eax
je     11bb <processInput+0x8b>
mov    0x2e47(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xe83(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
xorps  %xmm0,%xmm0
ucomiss -0x24(%rbp),%xmm0
ja     11de <processInput+0xae>
movss  -0x24(%rbp),%xmm0
movss  0xe2b(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    1208 <processInput+0xd8>
mov    0x2dfb(%rip),%rax
mov    (%rax),%edi
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe7c(%rip),%rsi
mov    $0x1,%al
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
movss  -0x24(%rbp),%xmm0
movss  0xdeb(%rip),%xmm1
divss  %xmm1,%xmm0
cvtsi2ssl -0x4(%rbp),%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<processInput>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
cmp    $0x2,%edx
jle    119b <processInput+0x6b>
mov    %rcx,%r14
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x10(%rsi),%rdi
lea    0xeda(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1040 <sscanf@plt>
cmp    $0x1,%eax
jne    11bc <processInput+0x8c>
movss  0xc(%rsp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm0,%xmm1
ja     11e1 <processInput+0xb1>
ucomiss 0xe8c(%rip),%xmm0
ja     11e1 <processInput+0xb1>
divss  0xe82(%rip),%xmm0
xorps  %xmm1,%xmm1
cvtsi2ss %ebp,%xmm1
mulss  %xmm0,%xmm1
cvttss2si %xmm1,%eax
mov    %eax,(%r14)
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
lea    0xe59(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
mov    0x10(%rbx),%rdx
lea    0xe5d(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    0x2df8(%rip),%rax
mov    (%rax),%edi
cvtss2sd %xmm0,%xmm0
lea    0xe7e(%rip),%rsi
mov    $0x1,%al
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [38 x i8] c"error: you must provide a percentage\0A\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [70 x i8] c"error: please provide a percentage between 0.0 and 100, you gave: %s\0A\00"
@.str.3 = [70 x i8] c"error: please provide a percentage between 0.0 and 100, you gave: %F\0A\00"
define i32 @processInput(i32 %0, i8** %1, i32 %2, i32* %3) {
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i32
%8 = alloca i32*
%9 = alloca float
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i32 %2, i32* %7
store i32* %3, i32** %8
%10 = load i32, i32* %7
%11 = icmp slt i32 %10, 3
br i1 %11, label %12, label %16
12: ; preds = %4
%13 = load i32, i32* @stderr
%14 = call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %4
%17 = load i8**, i8*** %6
%18 = getelementptr inbounds i8*, i8** %17, i64 2
%19 = load i8*, i8** %18
%20 = call i32 @sscanf(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %9)
%21 = icmp ne i32 %20, 1
br i1 %21, label %22, label %29
22: ; preds = %16
%23 = load i32, i32* @stderr
%24 = load i8**, i8*** %6
%25 = getelementptr inbounds i8*, i8** %24, i64 2
%26 = load i8*, i8** %25
%27 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.2, i64 0, i64 0), i8* %26)
%28 = call i32 @exit(i32 1)
unreachable
29: ; preds = %16
%30 = load float, float* %9
%31 = fcmp olt float %30, 0.000000e+00
br i1 %31, label %35, label %32
32: ; preds = %29
%33 = load float, float* %9
%34 = fcmp ogt float %33, 1.000000e+02
br i1 %34, label %35, label %41
35: ; preds = %32, %29
%36 = load i32, i32* @stderr
%37 = load float, float* %9
%38 = fpext float %37 to double
%39 = call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.3, i64 0, i64 0), double %38)
%40 = call i32 @exit(i32 1)
unreachable
41: ; preds = %32
%42 = load float, float* %9
%43 = fdiv float %42, 1.000000e+02
%44 = load i32, i32* %5
%45 = sitofp i32 %44 to float
%46 = fmul float %43, %45
%47 = fptosi float %46 to i32
%48 = load i32*, i32** %8
store i32 %47, i32* %48
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [38 x i8] c"error: you must provide a percentage\0A\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [70 x i8] c"error: please provide a percentage between 0.0 and 100, you gave: %s\0A\00"
@.str.3 = [70 x i8] c"error: please provide a percentage between 0.0 and 100, you gave: %F\0A\00"
define i32 @processInput(i32 %0, i8** nocapture %1, i32 %2, i32* nocapture writeonly %3) {
%5 = alloca float
%6 = icmp slt i32 %2, 3
br i1 %6, label %7, label %11
7: ; preds = %4
%8 = load i32, i32* @stderr
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %4
%12 = bitcast float* %5 to i8*
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
%15 = call i32 @sscanf(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %5)
%16 = icmp eq i32 %15, 1
br i1 %16, label %22, label %17
17: ; preds = %11
%18 = load i32, i32* @stderr
%19 = load i8*, i8** %13
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.2, i64 0, i64 0), i8* %19)
%21 = call i32 @exit(i32 1)
unreachable
22: ; preds = %11
%23 = load float, float* %5
%24 = fcmp olt float %23, 0.000000e+00
%25 = fcmp ogt float %23, 1.000000e+02
%26 = or i1 %24, %25
br i1 %26, label %27, label %32
27: ; preds = %22
%28 = load i32, i32* @stderr
%29 = fpext float %23 to double
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.3, i64 0, i64 0), double %29)
%31 = call i32 @exit(i32 1)
unreachable
32: ; preds = %22
%33 = fdiv float %23, 1.000000e+02
%34 = sitofp i32 %0 to float
%35 = fmul float %33, %34
%36 = fptosi float %35 to i32
store i32 %36, i32* %3
ret i32 0
}