#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*/ gen(char *, char *, char *, int);
int parsecondition(char *, int, char *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char **);
int strlen(char *);
int main() {
  int counter = 0, stlen = 0, elseflag = 0;
  char stmt[60];
  char strB[54];
  char strS1[50];
  char strS2[45];
  printf("format of if statement\n example............\n");
  printf("if(a<b)then(s,a);\n");
  printf("if(a<b)then(s,a) else (s,b);\n\n");
  printf("enter the statement\n");
  scanf("%s", &stmt);
  stlen = strlen(stmt);
  counter = counter + 2;
  counter = parsecondition(stmt, counter, strB, stlen);
  if (stmt[counter] == ')')
    counter++;
  counter = counter + 3;
  counter = parsecondition(stmt, counter, strS1, stlen);
  if (stmt[counter + 1] == ';') {
    printf("\n parsing the input statement...\n");
    gen(strB, strS1, strS2, elseflag);
    return 0;
  }
  if (stmt[counter] == ')')
    counter++;
  counter = counter + 3;
  counter = parsecondition(stmt, counter, strS2, stlen);
  counter = counter + 2;
  if (counter == stlen) {
    elseflag = 1;
    printf("\n parsing the input statement");
    gen(strB, strS1, strS2, elseflag);
    return 0;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xe82(%rip),%rdi
call   1040 <printf@plt>
lea    0xea3(%rip),%rdi
call   1040 <printf@plt>
lea    0xeaa(%rip),%rdi
call   1040 <printf@plt>
lea    0xebd(%rip),%rdi
call   1040 <printf@plt>
lea    -0x50(%rbp),%rsi
lea    0xec2(%rip),%rdi
call   1070 <scanf@plt>
lea    -0x50(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x8(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x8(%rbp),%esi
lea    -0x90(%rbp),%rdx
mov    -0xc(%rbp),%ecx
call   1050 <parsecondition@plt>
mov    %eax,-0x8(%rbp)
movslq -0x8(%rbp),%rax
movsbl -0x50(%rbp,%rax,1),%eax
cmp    $0x29,%eax
jne    1200 <main+0xb0>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x8(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x8(%rbp),%esi
lea    -0xd0(%rbp),%rdx
mov    -0xc(%rbp),%ecx
call   1050 <parsecondition@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cltq
movsbl -0x50(%rbp,%rax,1),%eax
cmp    $0x3b,%eax
jne    126d <main+0x11d>
lea    0xe38(%rip),%rdi
call   1040 <printf@plt>
lea    -0x90(%rbp),%rdi
lea    -0xd0(%rbp),%rsi
lea    -0x100(%rbp),%rdx
mov    -0x10(%rbp),%ecx
call   1060 <gen@plt>
movl   $0x0,-0x4(%rbp)
jmp    1302 <main+0x1b2>
movslq -0x8(%rbp),%rax
movsbl -0x50(%rbp,%rax,1),%eax
cmp    $0x29,%eax
jne    1288 <main+0x138>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x8(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x8(%rbp),%esi
lea    -0x100(%rbp),%rdx
mov    -0xc(%rbp),%ecx
call   1050 <parsecondition@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    12fb <main+0x1ab>
movl   $0x1,-0x10(%rbp)
lea    0xdcc(%rip),%rdi
call   1040 <printf@plt>
lea    -0x90(%rbp),%rdi
lea    -0xd0(%rbp),%rsi
lea    -0x100(%rbp),%rdx
mov    -0x10(%rbp),%ecx
call   1060 <gen@plt>
movl   $0x0,-0x4(%rbp)
jmp    1302 <main+0x1b2>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0xe8,%rsp
lea    0xeb0(%rip),%rdi
call   1030 <puts@plt>
lea    0xed0(%rip),%rdi
call   1030 <puts@plt>
lea    0xed6(%rip),%rdi
call   1030 <puts@plt>
lea    0xee8(%rip),%rdi
call   1030 <puts@plt>
lea    0xe5f(%rip),%rdi
mov    %rsp,%r14
mov    %r14,%rsi
call   1080 <scanf@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebx
lea    0xb0(%rsp),%rdx
mov    %r14,%rdi
mov    $0x2,%esi
mov    %eax,%ecx
call   1060 <parsecondition@plt>
cltq
xor    %ecx,%ecx
cmpb   $0x29,(%rsp,%rax,1)
sete   %cl
lea    (%rax,%rcx,1),%esi
add    $0x3,%esi
lea    0x70(%rsp),%rdx
mov    %r14,%rdi
mov    %ebx,%ecx
call   1060 <parsecondition@plt>
movslq %eax,%rsi
cmpb   $0x3b,0x1(%rsp,%rsi,1)
jne    1207 <main+0xa7>
lea    0xe93(%rip),%rdi
call   1030 <puts@plt>
xor    %ecx,%ecx
jmp    123c <main+0xdc>
cmpb   $0x29,(%rsp,%rsi,1)
lea    0x1(%rsi),%rax
cmove  %eax,%esi
add    $0x3,%esi
mov    %rsp,%rdi
lea    0x40(%rsp),%rdx
mov    %ebx,%ecx
call   1060 <parsecondition@plt>
add    $0x2,%eax
cmp    %ebx,%eax
jne    1253 <main+0xf3>
lea    0xdd1(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%ecx
lea    0xb0(%rsp),%rdi
lea    0x70(%rsp),%rsi
lea    0x40(%rsp),%rdx
call   1070 <gen@plt>
xor    %eax,%eax
add    $0xe8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [45 x i8] c"format of if statement\0A example............\0A\00"
@.str.1 = [19 x i8] c"if(a<b)then(s,a);\0A\00"
@.str.2 = [31 x i8] c"if(a<b)then(s,a) else (s,b);\0A\0A\00"
@.str.3 = [21 x i8] c"enter the statement\0A\00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [34 x i8] c"\0A parsing the input statement...\0A\00"
@.str.6 = [30 x i8] c"\0A parsing the input statement\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [60 x i8]
%6 = alloca [54 x i8]
%7 = alloca [50 x i8]
%8 = alloca [45 x i8]
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
%9 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%13 = bitcast [60 x i8]* %5 to i8**
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8** %13)
%15 = getelementptr inbounds [60 x i8], [60 x i8]* %5, i64 0, i64 0
%16 = call i32 @strlen(i8* %15)
store i32 %16, i32* %3
%17 = load i32, i32* %2
%18 = add nsw i32 %17, 2
store i32 %18, i32* %2
%19 = getelementptr inbounds [60 x i8], [60 x i8]* %5, i64 0, i64 0
%20 = load i32, i32* %2
%21 = getelementptr inbounds [54 x i8], [54 x i8]* %6, i64 0, i64 0
%22 = load i32, i32* %3
%23 = call i32 @parsecondition(i8* %19, i32 %20, i8* %21, i32 %22)
store i32 %23, i32* %2
%24 = load i32, i32* %2
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [60 x i8], [60 x i8]* %5, i64 0, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 41
br i1 %29, label %30, label %33
30: ; preds = %0
%31 = load i32, i32* %2
%32 = add nsw i32 %31, 1
store i32 %32, i32* %2
br label %33
33: ; preds = %30, %0
%34 = load i32, i32* %2
%35 = add nsw i32 %34, 3
store i32 %35, i32* %2
%36 = getelementptr inbounds [60 x i8], [60 x i8]* %5, i64 0, i64 0
%37 = load i32, i32* %2
%38 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%39 = load i32, i32* %3
%40 = call i32 @parsecondition(i8* %36, i32 %37, i8* %38, i32 %39)
store i32 %40, i32* %2
%41 = load i32, i32* %2
%42 = add nsw i32 %41, 1
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [60 x i8], [60 x i8]* %5, i64 0, i64 %43
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp eq i32 %46, 59
br i1 %47, label %48, label %55
48: ; preds = %33
%49 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0))
%50 = getelementptr inbounds [54 x i8], [54 x i8]* %6, i64 0, i64 0
%51 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%52 = getelementptr inbounds [45 x i8], [45 x i8]* %8, i64 0, i64 0
%53 = load i32, i32* %4
%54 = call i32 @gen(i8* %50, i8* %51, i8* %52, i32 %53)
store i32 0, i32* %1
br label %86
55: ; preds = %33
%56 = load i32, i32* %2
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [60 x i8], [60 x i8]* %5, i64 0, i64 %57
%59 = load i8, i8* %58
%60 = sext i8 %59 to i32
%61 = icmp eq i32 %60, 41
br i1 %61, label %62, label %65
62: ; preds = %55
%63 = load i32, i32* %2
%64 = add nsw i32 %63, 1
store i32 %64, i32* %2
br label %65
65: ; preds = %62, %55
%66 = load i32, i32* %2
%67 = add nsw i32 %66, 3
store i32 %67, i32* %2
%68 = getelementptr inbounds [60 x i8], [60 x i8]* %5, i64 0, i64 0
%69 = load i32, i32* %2
%70 = getelementptr inbounds [45 x i8], [45 x i8]* %8, i64 0, i64 0
%71 = load i32, i32* %3
%72 = call i32 @parsecondition(i8* %68, i32 %69, i8* %70, i32 %71)
store i32 %72, i32* %2
%73 = load i32, i32* %2
%74 = add nsw i32 %73, 2
store i32 %74, i32* %2
%75 = load i32, i32* %2
%76 = load i32, i32* %3
%77 = icmp eq i32 %75, %76
br i1 %77, label %78, label %85
78: ; preds = %65
store i32 1, i32* %4
%79 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0))
%80 = getelementptr inbounds [54 x i8], [54 x i8]* %6, i64 0, i64 0
%81 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%82 = getelementptr inbounds [45 x i8], [45 x i8]* %8, i64 0, i64 0
%83 = load i32, i32* %4
%84 = call i32 @gen(i8* %80, i8* %81, i8* %82, i32 %83)
store i32 0, i32* %1
br label %86
85: ; preds = %65
store i32 0, i32* %1
br label %86
86: ; preds = %85, %78, %48
%87 = load i32, i32* %1
ret i32 %87
}

LLVM IR (-O2):
@.str.4 = [3 x i8] c"%s\00"
@.str.6 = [30 x i8] c"\0A parsing the input statement\00"
@str = [44 x i8] c"format of if statement\0A example............\00"
@str.7 = [18 x i8] c"if(a<b)then(s,a);\00"
@str.8 = [30 x i8] c"if(a<b)then(s,a) else (s,b);\0A\00"
@str.9 = [20 x i8] c"enter the statement\00"
@str.10 = [33 x i8] c"\0A parsing the input statement...\00"
define i32 @main() {
%1 = alloca [60 x i8]
%2 = alloca [54 x i8]
%3 = alloca [50 x i8]
%4 = alloca [45 x i8]
%5 = getelementptr inbounds [60 x i8], [60 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [54 x i8], [54 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [45 x i8], [45 x i8]* %4, i64 0, i64 0
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.7, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.8, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.9, i64 0, i64 0))
%13 = bitcast [60 x i8]* %1 to i8**
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8** %13)
%15 = call i32 @strlen(i8* %5)
%16 = call i32 @parsecondition(i8* %5, i32 2, i8* %6, i32 %15)
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [60 x i8], [60 x i8]* %1, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 41
%21 = zext i1 %20 to i32
%22 = add i32 %16, 3
%23 = add i32 %22, %21
%24 = call i32 @parsecondition(i8* %5, i32 %23, i8* %7, i32 %15)
%25 = add nsw i32 %24, 1
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [60 x i8], [60 x i8]* %1, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = icmp eq i8 %28, 59
br i1 %29, label %30, label %32
30: ; preds = %0
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.10, i64 0, i64 0))
br label %44
32: ; preds = %0
%33 = sext i32 %24 to i64
%34 = getelementptr inbounds [60 x i8], [60 x i8]* %1, i64 0, i64 %33
%35 = load i8, i8* %34
%36 = icmp eq i8 %35, 41
%37 = select i1 %36, i32 %25, i32 %24
%38 = add nsw i32 %37, 3
%39 = call i32 @parsecondition(i8* %5, i32 %38, i8* %8, i32 %15)
%40 = add nsw i32 %39, 2
%41 = icmp eq i32 %40, %15
br i1 %41, label %42, label %47
42: ; preds = %32
%43 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0))
br label %44
44: ; preds = %30, %42
%45 = phi i32 [ 1, %42 ], [ 0, %30 ]
%46 = call i32 @gen(i8* %6, i8* %7, i8* %8, i32 %45)
br label %47
47: ; preds = %44, %32
ret i32 0
}