#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 */
char EOF;
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ ungetc(char, int /*<<< orphan*/ *);
char lang_skipFunction(FILE *lang_in) {
  int level;
  char c;
  level = 1;
  c = fgetc(lang_in);
  while (c != '{' && c != EOF) {
    c = fgetc(lang_in);
  }
  c = fgetc(lang_in);
  while (level > 0) {
    if (c == '{')
      ++level;
    else if (c == '}')
      --level;
    c = fgetc(lang_in);
  }
  ungetc(c, lang_in);
  return 0;
}


x86 assembly (clang, -O0):
<lang_skipFunction>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0xd(%rbp)
movsbl -0xd(%rbp),%ecx
xor    %eax,%eax
cmp    $0x7b,%ecx
mov    %al,-0xe(%rbp)
je     1167 <lang_skipFunction+0x47>
movsbl -0xd(%rbp),%eax
mov    0x2e8c(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0xe(%rbp)
mov    -0xe(%rbp),%al
test   $0x1,%al
jne    1177 <lang_skipFunction+0x57>
jmp    1188 <lang_skipFunction+0x68>
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0xd(%rbp)
jmp    113f <lang_skipFunction+0x1f>
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0xd(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    11e5 <lang_skipFunction+0xc5>
movsbl -0xd(%rbp),%eax
cmp    $0x7b,%eax
jne    11b9 <lang_skipFunction+0x99>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11d4 <lang_skipFunction+0xb4>
movsbl -0xd(%rbp),%eax
cmp    $0x7d,%eax
jne    11cf <lang_skipFunction+0xaf>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    11d4 <lang_skipFunction+0xb4>
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0xd(%rbp)
jmp    1194 <lang_skipFunction+0x74>
mov    -0xd(%rbp),%al
mov    -0x8(%rbp),%rsi
movsbl %al,%edi
call   1040 <ungetc@plt>
xor    %eax,%eax
movsbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lang_skipFunction>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <fgetc@plt>
cmp    $0x7b,%al
je     1151 <lang_skipFunction+0x31>
mov    0x2eb2(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
cmp    0x0(%rbp),%al
je     1151 <lang_skipFunction+0x31>
mov    %rbx,%rdi
call   1030 <fgetc@plt>
cmp    $0x7b,%al
jne    1140 <lang_skipFunction+0x20>
mov    %rbx,%rdi
call   1030 <fgetc@plt>
mov    $0x1,%ebp
jmp    116f <lang_skipFunction+0x4f>
add    $0xffffffff,%ebp
mov    %rbx,%rdi
call   1030 <fgetc@plt>
test   %ebp,%ebp
jle    117c <lang_skipFunction+0x5c>
cmp    $0x7d,%al
je     1160 <lang_skipFunction+0x40>
cmp    $0x7b,%al
jne    1163 <lang_skipFunction+0x43>
add    $0x1,%ebp
jmp    1163 <lang_skipFunction+0x43>
movsbl %al,%edi
mov    %rbx,%rsi
call   1040 <ungetc@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i8 0
define signext i8 @lang_skipFunction(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i8
store i32* %0, i32** %2
store i32 1, i32* %3
%5 = load i32*, i32** %2
%6 = call signext i8 @fgetc(i32* %5)
store i8 %6, i8* %4
br label %7
7: ; preds = %19, %1
%8 = load i8, i8* %4
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 123
br i1 %10, label %11, label %17
11: ; preds = %7
%12 = load i8, i8* %4
%13 = sext i8 %12 to i32
%14 = load i8, i8* @EOF
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %13, %15
br label %17
17: ; preds = %11, %7
%18 = phi i1 [ false, %7 ], [ %16, %11 ]
br i1 %18, label %19, label %22
19: ; preds = %17
%20 = load i32*, i32** %2
%21 = call signext i8 @fgetc(i32* %20)
store i8 %21, i8* %4
br label %7
22: ; preds = %17
%23 = load i32*, i32** %2
%24 = call signext i8 @fgetc(i32* %23)
store i8 %24, i8* %4
br label %25
25: ; preds = %43, %22
%26 = load i32, i32* %3
%27 = icmp sgt i32 %26, 0
br i1 %27, label %28, label %46
28: ; preds = %25
%29 = load i8, i8* %4
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 123
br i1 %31, label %32, label %35
32: ; preds = %28
%33 = load i32, i32* %3
%34 = add nsw i32 %33, 1
store i32 %34, i32* %3
br label %43
35: ; preds = %28
%36 = load i8, i8* %4
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %37, 125
br i1 %38, label %39, label %42
39: ; preds = %35
%40 = load i32, i32* %3
%41 = add nsw i32 %40, -1
store i32 %41, i32* %3
br label %42
42: ; preds = %39, %35
br label %43
43: ; preds = %42, %32
%44 = load i32*, i32** %2
%45 = call signext i8 @fgetc(i32* %44)
store i8 %45, i8* %4
br label %25
46: ; preds = %25
%47 = load i8, i8* %4
%48 = load i32*, i32** %2
%49 = call i32 @ungetc(i8 signext %47, i32* %48)
ret i8 0
}

LLVM IR (-O2):
@EOF = global i8 0
define signext i8 @lang_skipFunction(i32* nocapture %0) {
%2 = tail call signext i8 @fgetc(i32* %0)
%3 = icmp ne i8 %2, 123
%4 = load i8, i8* @EOF
%5 = icmp ne i8 %2, %4
%6 = select i1 %3, i1 %5, i1 false
br i1 %6, label %7, label %13
7: ; preds = %1, %7
%8 = tail call signext i8 @fgetc(i32* %0)
%9 = icmp ne i8 %8, 123
%10 = load i8, i8* @EOF
%11 = icmp ne i8 %8, %10
%12 = select i1 %9, i1 %11, i1 false
br i1 %12, label %7, label %13
13: ; preds = %7, %1
%14 = tail call signext i8 @fgetc(i32* %0)
br label %15
15: ; preds = %13, %22
%16 = phi i8 [ %14, %13 ], [ %24, %22 ]
%17 = phi i32 [ 1, %13 ], [ %23, %22 ]
switch i8 %16, label %22 [
i8 123, label %18
i8 125, label %20
]
18: ; preds = %15
%19 = add nuw nsw i32 %17, 1
br label %22
20: ; preds = %15
%21 = add nsw i32 %17, -1
br label %22
22: ; preds = %15, %20, %18
%23 = phi i32 [ %19, %18 ], [ %21, %20 ], [ %17, %15 ]
%24 = tail call signext i8 @fgetc(i32* %0)
%25 = icmp sgt i32 %23, 0
br i1 %25, label %15, label %26
26: ; preds = %22
%27 = tail call i32 @ungetc(i8 signext %24, i32* %0)
ret i8 0
}