#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_CUR;
int /*<<< orphan*/ clearArray(char *, int);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ nextText(int /*<<< orphan*/ *, char *, char *, char *, int);
int /*<<< orphan*/ printf(char *, int, char, int);
int /*<<< orphan*/ skipBlank(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strlen(char *);
int parseConditionBlock(FILE *f, char *buffer, int buffer_size,
                        char *condition) {
  int is_mono_intruction = 0, count_opened = 1;
  char tmp[128] = {0};
  while (count_opened != 0 || (count_opened == 0 && tmp[0] != ')')) {
    clearArray(tmp, 128);
    nextText(f, "%[^()]", tmp, buffer, buffer_size);
    strcat(condition, tmp);
    clearArray(tmp, 128);
    fscanf(f, "%c", &tmp[0]);
    if (tmp[0] == '(')
      count_opened++;
    else if (tmp[0] == ')')
      count_opened--;
    if (count_opened && (tmp[0] == '(' || tmp[0] == ')'))
      strcat(condition, tmp);
    printf("parse block cond : %d, %c, %d\n", (int)strlen(tmp), tmp[0],
           count_opened);
  }
  skipBlank(f, buffer, buffer_size);
  clearArray(tmp, 128);
  nextText(f, "%1[{]", tmp, buffer, buffer_size);
  if (tmp[0])
    fseek(f, -1, SEEK_CUR);
  else
    is_mono_intruction = 1;
  return is_mono_intruction;
}


x86 assembly (clang, -O0):
<parseConditionBlock>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x1,-0x28(%rbp)
lea    -0xb0(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1070 <memset@plt>
mov    $0x1,%al
cmpl   $0x0,-0x28(%rbp)
mov    %al,-0xb1(%rbp)
jne    120e <parseConditionBlock+0x7e>
xor    %eax,%eax
cmpl   $0x0,-0x28(%rbp)
mov    %al,-0xb2(%rbp)
jne    1202 <parseConditionBlock+0x72>
movsbl -0xb0(%rbp),%eax
cmp    $0x29,%eax
setne  %al
mov    %al,-0xb2(%rbp)
mov    -0xb2(%rbp),%al
mov    %al,-0xb1(%rbp)
mov    -0xb1(%rbp),%al
test   $0x1,%al
jne    1221 <parseConditionBlock+0x91>
jmp    132a <parseConditionBlock+0x19a>
lea    -0xb0(%rbp),%rdi
mov    $0x80,%esi
call   1060 <clearArray@plt>
mov    -0x8(%rbp),%rdi
lea    -0xb0(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    -0x14(%rbp),%r8d
lea    0xdb4(%rip),%rsi
call   1030 <nextText@plt>
mov    -0x20(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
call   10a0 <strcat@plt>
lea    -0xb0(%rbp),%rdi
mov    $0x80,%esi
call   1060 <clearArray@plt>
mov    -0x8(%rbp),%rdi
lea    -0xb0(%rbp),%rdx
lea    0xd83(%rip),%rsi
call   1080 <fscanf@plt>
movsbl -0xb0(%rbp),%eax
cmp    $0x28,%eax
jne    12a7 <parseConditionBlock+0x117>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    12c5 <parseConditionBlock+0x135>
movsbl -0xb0(%rbp),%eax
cmp    $0x29,%eax
jne    12c0 <parseConditionBlock+0x130>
mov    -0x28(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x28(%rbp)
jmp    12c5 <parseConditionBlock+0x135>
cmpl   $0x0,-0x28(%rbp)
je     12ff <parseConditionBlock+0x16f>
movsbl -0xb0(%rbp),%eax
cmp    $0x28,%eax
je     12ef <parseConditionBlock+0x15f>
movsbl -0xb0(%rbp),%eax
cmp    $0x29,%eax
jne    12ff <parseConditionBlock+0x16f>
mov    -0x20(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
call   10a0 <strcat@plt>
lea    -0xb0(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%esi
mov    -0xb0(%rbp),%al
mov    -0x28(%rbp),%ecx
lea    0xced(%rip),%rdi
movsbl %al,%edx
call   1050 <printf@plt>
jmp    11cb <parseConditionBlock+0x3b>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   10b0 <skipBlank@plt>
lea    -0xb0(%rbp),%rdi
mov    $0x80,%esi
call   1060 <clearArray@plt>
mov    -0x8(%rbp),%rdi
lea    -0xb0(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    -0x14(%rbp),%r8d
lea    0xcc4(%rip),%rsi
call   1030 <nextText@plt>
cmpb   $0x0,-0xb0(%rbp)
je     1393 <parseConditionBlock+0x203>
mov    -0x8(%rbp),%rdi
mov    0x2c66(%rip),%rax
mov    (%rax),%edx
mov    $0xffffffff,%esi
call   1090 <fseek@plt>
jmp    139a <parseConditionBlock+0x20a>
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseConditionBlock>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %rcx,%r12
mov    %edx,0xc(%rsp)
mov    %rsi,%r15
mov    %rdi,%r13
xorps  %xmm0,%xmm0
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
mov    $0x1,%ebp
lea    0x10(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x80,%esi
call   1060 <clearArray@plt>
mov    %r13,%rdi
lea    0xe09(%rip),%rsi
mov    %rbx,%rdx
mov    %r15,%rcx
mov    0xc(%rsp),%r8d
call   1030 <nextText@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1090 <strcat@plt>
mov    %rbx,%rdi
mov    $0x80,%esi
call   1060 <clearArray@plt>
mov    %r13,%rdi
lea    0xdde(%rip),%rsi
mov    %rbx,%rdx
call   1070 <fscanf@plt>
movzbl 0x10(%rsp),%r14d
cmp    $0x29,%r14b
je     1250 <parseConditionBlock+0xd0>
cmp    $0x28,%r14b
jne    1246 <parseConditionBlock+0xc6>
add    $0x1,%ebp
test   %ebp,%ebp
jne    1257 <parseConditionBlock+0xd7>
jmp    1271 <parseConditionBlock+0xf1>
nopl   0x0(%rax)
add    $0xffffffff,%ebp
test   %ebp,%ebp
je     1271 <parseConditionBlock+0xf1>
mov    %r14d,%eax
and    $0xfe,%al
cmp    $0x28,%al
jne    1271 <parseConditionBlock+0xf1>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1090 <strcat@plt>
movzbl 0x10(%rsp),%r14d
mov    %rbx,%rdi
call   1040 <strlen@plt>
movsbl %r14b,%edx
lea    0xd86(%rip),%rdi
mov    %eax,%esi
mov    %ebp,%ecx
call   1050 <printf@plt>
test   %ebp,%ebp
jne    11e0 <parseConditionBlock+0x60>
cmpb   $0x29,0x10(%rsp)
jne    11e0 <parseConditionBlock+0x60>
mov    %r13,%rdi
mov    %r15,%rbp
mov    %r15,%rsi
mov    0xc(%rsp),%r15d
mov    %r15d,%edx
call   10a0 <skipBlank@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x80,%esi
call   1060 <clearArray@plt>
lea    0xd5a(%rip),%rsi
mov    %r13,%rdi
mov    %rbx,%rdx
mov    %rbp,%rcx
mov    %r15d,%r8d
call   1030 <nextText@plt>
cmpb   $0x0,0x10(%rsp)
je     1301 <parseConditionBlock+0x181>
mov    0x2cfa(%rip),%rax
mov    (%rax),%edx
mov    %r13,%rdi
mov    $0xffffffff,%esi
call   1080 <fseek@plt>
xor    %eax,%eax
jmp    1306 <parseConditionBlock+0x186>
mov    $0x1,%eax
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%[^()]\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [31 x i8] c"parse block cond : %d, %c, %d\0A\00"
@.str.3 = [6 x i8] c"%1[{]\00"
@SEEK_CUR = global i32 0
define i32 @parseConditionBlock(i32* %0, i8* %1, i32 %2, i8* %3) {
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca [128 x i8]
store i32* %0, i32** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i8* %3, i8** %8
store i32 0, i32* %9
store i32 1, i32* %10
%12 = bitcast [128 x i8]* %11 to i8*
br label %13
13: ; preds = %77, %4
%14 = load i32, i32* %10
%15 = icmp ne i32 %14, 0
br i1 %15, label %26, label %16
16: ; preds = %13
%17 = load i32, i32* %10
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %24
19: ; preds = %16
%20 = getelementptr inbounds [128 x i8], [128 x i8]* %11, i64 0, i64 0
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 41
br label %24
24: ; preds = %19, %16
%25 = phi i1 [ false, %16 ], [ %23, %19 ]
br label %26
26: ; preds = %24, %13
%27 = phi i1 [ true, %13 ], [ %25, %24 ]
br i1 %27, label %28, label %85
28: ; preds = %26
%29 = getelementptr inbounds [128 x i8], [128 x i8]* %11, i64 0, i64 0
%30 = call i32 @clearArray(i8* %29, i32 128)
%31 = load i32*, i32** %5
%32 = getelementptr inbounds [128 x i8], [128 x i8]* %11, i64 0, i64 0
%33 = load i8*, i8** %6
%34 = load i32, i32* %7
%35 = call i32 @nextText(i32* %31, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %32, i8* %33, i32 %34)
%36 = load i8*, i8** %8
%37 = getelementptr inbounds [128 x i8], [128 x i8]* %11, i64 0, i64 0
%38 = call i32 @strcat(i8* %36, i8* %37)
%39 = getelementptr inbounds [128 x i8], [128 x i8]* %11, i64 0, i64 0
%40 = call i32 @clearArray(i8* %39, i32 128)
%41 = load i32*, i32** %5
%42 = getelementptr inbounds [128 x i8], [128 x i8]* %11, i64 0, i64 0
%43 = call i32 @fscanf(i32* %41, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %42)
%44 = getelementptr inbounds [128 x i8], [128 x i8]* %11, i64 0, i64 0
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp eq i32 %46, 40
br i1 %47, label %48, label %51
48: ; preds = %28
%49 = load i32, i32* %10
%50 = add nsw i32 %49, 1
store i32 %50, i32* %10
br label %60
51: ; preds = %28
%52 = getelementptr inbounds [128 x i8], [128 x i8]* %11, i64 0, i64 0
%53 = load i8, i8* %52
%54 = sext i8 %53 to i32
%55 = icmp eq i32 %54, 41
br i1 %55, label %56, label %59
56: ; preds = %51
%57 = load i32, i32* %10
%58 = add nsw i32 %57, -1
store i32 %58, i32* %10
br label %59
59: ; preds = %56, %51
br label %60
60: ; preds = %59, %48
%61 = load i32, i32* %10
%62 = icmp ne i32 %61, 0
br i1 %62, label %63, label %77
63: ; preds = %60
%64 = getelementptr inbounds [128 x i8], [128 x i8]* %11, i64 0, i64 0
%65 = load i8, i8* %64
%66 = sext i8 %65 to i32
%67 = icmp eq i32 %66, 40
br i1 %67, label %73, label %68
68: ; preds = %63
%69 = getelementptr inbounds [128 x i8], [128 x i8]* %11, i64 0, i64 0
%70 = load i8, i8* %69
%71 = sext i8 %70 to i32
%72 = icmp eq i32 %71, 41
br i1 %72, label %73, label %77
73: ; preds = %68, %63
%74 = load i8*, i8** %8
%75 = getelementptr inbounds [128 x i8], [128 x i8]* %11, i64 0, i64 0
%76 = call i32 @strcat(i8* %74, i8* %75)
br label %77
77: ; preds = %73, %68, %60
%78 = getelementptr inbounds [128 x i8], [128 x i8]* %11, i64 0, i64 0
%79 = call i64 @strlen(i8* %78)
%80 = trunc i64 %79 to i32
%81 = getelementptr inbounds [128 x i8], [128 x i8]* %11, i64 0, i64 0
%82 = load i8, i8* %81
%83 = load i32, i32* %10
%84 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 %80, i8 signext %82, i32 %83)
br label %13
85: ; preds = %26
%86 = load i32*, i32** %5
%87 = load i8*, i8** %6
%88 = load i32, i32* %7
%89 = call i32 @skipBlank(i32* %86, i8* %87, i32 %88)
%90 = getelementptr inbounds [128 x i8], [128 x i8]* %11, i64 0, i64 0
%91 = call i32 @clearArray(i8* %90, i32 128)
%92 = load i32*, i32** %5
%93 = getelementptr inbounds [128 x i8], [128 x i8]* %11, i64 0, i64 0
%94 = load i8*, i8** %6
%95 = load i32, i32* %7
%96 = call i32 @nextText(i32* %92, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %93, i8* %94, i32 %95)
%97 = getelementptr inbounds [128 x i8], [128 x i8]* %11, i64 0, i64 0
%98 = load i8, i8* %97
%99 = icmp ne i8 %98, 0
br i1 %99, label %100, label %104
100: ; preds = %85
%101 = load i32*, i32** %5
%102 = load i32, i32* @SEEK_CUR
%103 = call i32 @fseek(i32* %101, i32 -1, i32 %102)
br label %105
104: ; preds = %85
store i32 1, i32* %9
br label %105
105: ; preds = %104, %100
%106 = load i32, i32* %9
ret i32 %106
}

LLVM IR (-O2):
@.str = [7 x i8] c"%[^()]\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [31 x i8] c"parse block cond : %d, %c, %d\0A\00"
@.str.3 = [6 x i8] c"%1[{]\00"
@SEEK_CUR = global i32 0
define i32 @parseConditionBlock(i32* %0, i8* %1, i32 %2, i8* %3) {
%5 = alloca [128 x i8]
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
br label %7
7: ; preds = %4, %28
%8 = phi i32 [ 1, %4 ], [ %20, %28 ]
%9 = call i32 @clearArray(i8* %6, i32 128)
%10 = call i32 @nextText(i32* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %6, i8* %1, i32 %2)
%11 = call i32 @strcat(i8* %3, i8* %6)
%12 = call i32 @clearArray(i8* %6, i32 128)
%13 = call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%14 = load i8, i8* %6
switch i8 %14, label %19 [
i8 40, label %15
i8 41, label %17
]
15: ; preds = %7
%16 = add nsw i32 %8, 1
br label %19
17: ; preds = %7
%18 = add nsw i32 %8, -1
br label %19
19: ; preds = %7, %17, %15
%20 = phi i32 [ %16, %15 ], [ %18, %17 ], [ %8, %7 ]
%21 = icmp ne i32 %20, 0
%22 = and i8 %14, -2
%23 = icmp eq i8 %22, 40
%24 = select i1 %21, i1 %23, i1 false
br i1 %24, label %25, label %28
25: ; preds = %19
%26 = call i32 @strcat(i8* %3, i8* %6)
%27 = load i8, i8* %6
br label %28
28: ; preds = %25, %19
%29 = phi i8 [ %27, %25 ], [ %14, %19 ]
%30 = call i64 @strlen(i8* %6)
%31 = trunc i64 %30 to i32
%32 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 %31, i8 signext %29, i32 %20)
%33 = icmp eq i32 %20, 0
%34 = load i8, i8* %6
%35 = icmp eq i8 %34, 41
%36 = select i1 %33, i1 %35, i1 false
br i1 %36, label %37, label %7
37: ; preds = %28
%38 = call i32 @skipBlank(i32* %0, i8* %1, i32 %2)
%39 = call i32 @clearArray(i8* %6, i32 128)
%40 = call i32 @nextText(i32* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %6, i8* %1, i32 %2)
%41 = load i8, i8* %6
%42 = icmp eq i8 %41, 0
br i1 %42, label %46, label %43
43: ; preds = %37
%44 = load i32, i32* @SEEK_CUR
%45 = call i32 @fseek(i32* %0, i32 -1, i32 %44)
br label %46
46: ; preds = %37, %43
%47 = phi i32 [ 0, %43 ], [ 1, %37 ]
ret i32 %47
}