#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 */
double atof(char *);
int atoi(char *);
int /*<<< orphan*/ set_var(char *, int, double, int, char *);
int /*<<< orphan*/ sscanf(char *, char *, char *, char *);
unsigned int strlen(char *);
scalar_t__ tolower(char);
char toupper(char);
void parse_argument(int argc, char *argv[]) {
  int j;
  unsigned int i;
  char name[100], strval[100];
  double dval;
  int ival;
  int bool_val;
  char testbool;
  for (j = 0; j < argc; j++) {
    sscanf(argv[j], "%32[^=]=%s", name, strval);
    dval = atof(strval);
    ival = atoi(strval);
    testbool = toupper(strval[0]);
    if (testbool == 'Y')
      bool_val = 1;
    else
      bool_val = 0;
    for (i = 0; i < strlen(name); i++)
      name[i] = (char)tolower(name[i]);
    set_var(name, ival, dval, bool_val, strval);
  }
  return;
}


x86 assembly (clang, -O0):
<parse_argument>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1298 <parse_argument+0x128>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x80(%rbp),%rdx
lea    -0xf0(%rbp),%rcx
lea    0xe4d(%rip),%rsi
call   1080 <sscanf@plt>
lea    -0xf0(%rbp),%rdi
call   1040 <atof@plt>
movsd  %xmm0,-0xf8(%rbp)
ff
lea    -0xf0(%rbp),%rdi
call   1090 <atoi@plt>
mov    %eax,-0xfc(%rbp)
movsbl -0xf0(%rbp),%edi
call   1030 <toupper@plt>
mov    %al,-0x101(%rbp)
movsbl -0x101(%rbp),%eax
cmp    $0x59,%eax
jne    120f <parse_argument+0x9f>
movl   $0x1,-0x100(%rbp)
jmp    1219 <parse_argument+0xa9>
movl   $0x0,-0x100(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x108(%rbp)
lea    -0x80(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x108(%rbp),%eax
cmp    %ecx,%eax
jae    1266 <parse_argument+0xf6>
mov    -0x18(%rbp),%eax
movsbl -0x80(%rbp,%rax,1),%edi
call   1070 <tolower@plt>
mov    %al,%cl
mov    -0x18(%rbp),%eax
mov    %cl,-0x80(%rbp,%rax,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1220 <parse_argument+0xb0>
lea    -0x80(%rbp),%rdi
mov    -0xfc(%rbp),%esi
movsd  -0xf8(%rbp),%xmm0
ff
mov    -0x100(%rbp),%edx
lea    -0xf0(%rbp),%rcx
call   1060 <set_var@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1189 <parse_argument+0x19>
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_argument>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xf8,%rsp
mov    %rsi,0x10(%rsp)
test   %edi,%edi
jle    126e <parse_argument+0xfe>
mov    %edi,%eax
mov    %rax,0x8(%rsp)
xor    %r15d,%r15d
lea    0x90(%rsp),%rbx
lea    0x20(%rsp),%rbp
jmp    11dd <parse_argument+0x6d>
nopw   0x0(%rax,%rax,1)
mov    %r14b,%bpl
mov    %rbx,%rdi
mov    %r13d,%esi
movsd  0x18(%rsp),%xmm0
mov    %ebp,%edx
lea    0x20(%rsp),%rbp
mov    %rbp,%rcx
call   1060 <set_var@plt>
add    $0x1,%r15
cmp    0x8(%rsp),%r15
je     126e <parse_argument+0xfe>
mov    0x10(%rsp),%rax
mov    (%rax,%r15,8),%rdi
lea    0xe13(%rip),%rsi
mov    %rbx,%rdx
mov    %rbp,%rcx
call   1080 <sscanf@plt>
mov    %rbp,%rdi
call   1040 <atof@plt>
movsd  %xmm0,0x18(%rsp)
mov    %rbp,%rdi
call   1090 <atoi@plt>
mov    %eax,%r13d
movsbl 0x20(%rsp),%edi
call   1030 <toupper@plt>
xor    %ebp,%ebp
cmp    $0x59,%al
sete   %r14b
mov    %rbx,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
je     11b0 <parse_argument+0x40>
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl 0x90(%rsp,%r12,1),%edi
call   1070 <tolower@plt>
mov    %al,0x90(%rsp,%r12,1)
add    $0x1,%r12
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %eax,%eax
cmp    %rax,%r12
jb     1240 <parse_argument+0xd0>
jmp    11b0 <parse_argument+0x40>
add    $0xf8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"%32[^=]=%s\00"
define void @parse_argument(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
%7 = alloca [100 x i8]
%8 = alloca [100 x i8]
%9 = alloca double
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8
store i32 %0, i32* %3
store i8** %1, i8*** %4
store i32 0, i32* %5
br label %13
13: ; preds = %64, %2
%14 = load i32, i32* %5
%15 = load i32, i32* %3
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %67
17: ; preds = %13
%18 = load i8**, i8*** %4
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8*, i8** %18, i64 %20
%22 = load i8*, i8** %21
%23 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%25 = call i32 @sscanf(i8* %22, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %23, i8* %24)
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%27 = call double @atof(i8* %26)
store double %27, double* %9
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%29 = call i32 @atoi(i8* %28)
store i32 %29, i32* %10
%30 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%31 = load i8, i8* %30
%32 = call signext i8 @toupper(i8 signext %31)
store i8 %32, i8* %12
%33 = load i8, i8* %12
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 89
br i1 %35, label %36, label %37
36: ; preds = %17
store i32 1, i32* %11
br label %38
37: ; preds = %17
store i32 0, i32* %11
br label %38
38: ; preds = %37, %36
store i32 0, i32* %6
br label %39
39: ; preds = %54, %38
%40 = load i32, i32* %6
%41 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%42 = call i32 @strlen(i8* %41)
%43 = icmp ult i32 %40, %42
br i1 %43, label %44, label %57
44: ; preds = %39
%45 = load i32, i32* %6
%46 = zext i32 %45 to i64
%47 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 %46
%48 = load i8, i8* %47
%49 = call i64 @tolower(i8 signext %48)
%50 = trunc i64 %49 to i8
%51 = load i32, i32* %6
%52 = zext i32 %51 to i64
%53 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 %52
store i8 %50, i8* %53
br label %54
54: ; preds = %44
%55 = load i32, i32* %6
%56 = add i32 %55, 1
store i32 %56, i32* %6
br label %39
57: ; preds = %39
%58 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%59 = load i32, i32* %10
%60 = load double, double* %9
%61 = load i32, i32* %11
%62 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%63 = call i32 @set_var(i8* %58, i32 %59, double %60, i32 %61, i8* %62)
br label %64
64: ; preds = %57
%65 = load i32, i32* %5
%66 = add nsw i32 %65, 1
store i32 %66, i32* %5
br label %13
67: ; preds = %13
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"%32[^=]=%s\00"
define void @parse_argument(i32 %0, i8** nocapture %1) {
%3 = alloca [100 x i8]
%4 = alloca [100 x i8]
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%7 = icmp sgt i32 %0, 0
br i1 %7, label %8, label %37
8: ; preds = %2
%9 = zext i32 %0 to i64
br label %10
10: ; preds = %8, %33
%11 = phi i64 [ 0, %8 ], [ %35, %33 ]
%12 = getelementptr inbounds i8*, i8** %1, i64 %11
%13 = load i8*, i8** %12
%14 = call i32 @sscanf(i8* %13, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %5, i8* %6)
%15 = call double @atof(i8* %6)
%16 = call i32 @atoi(i8* %6)
%17 = load i8, i8* %6
%18 = call signext i8 @toupper(i8 signext %17)
%19 = icmp eq i8 %18, 89
%20 = zext i1 %19 to i32
%21 = call i32 @strlen(i8* %5)
%22 = icmp eq i32 %21, 0
br i1 %22, label %33, label %23
23: ; preds = %10, %23
%24 = phi i64 [ %29, %23 ], [ 0, %10 ]
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = call i64 @tolower(i8 signext %26)
%28 = trunc i64 %27 to i8
store i8 %28, i8* %25
%29 = add nuw nsw i64 %24, 1
%30 = call i32 @strlen(i8* %5)
%31 = zext i32 %30 to i64
%32 = icmp ult i64 %29, %31
br i1 %32, label %23, label %33
33: ; preds = %23, %10
%34 = call i32 @set_var(i8* %5, i32 %16, double %15, i32 %20, i8* %6)
%35 = add nuw nsw i64 %11, 1
%36 = icmp eq i64 %35, %9
br i1 %36, label %37, label %10
37: ; preds = %33, %2
ret void
}