#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 EOF;
int fgetc(int /*<<< orphan*/ *);
void skip_loop(FILE *in) {
  int depth = 0;
  int c;
  while ((c = fgetc(in)) != EOF) {
    if (c == '[') {
      ++depth;
    } else if (c == ']') {
      if (depth == 0) {
        break;
      } else {
        --depth;
      }
    }
  }
}


x86 assembly (clang, -O0):
<skip_loop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %eax,-0x10(%rbp)
mov    0x2eb2(%rip),%rcx
cmp    (%rcx),%eax
je     1187 <skip_loop+0x77>
cmpl   $0x5b,-0x10(%rbp)
jne    1156 <skip_loop+0x46>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1182 <skip_loop+0x72>
cmpl   $0x5d,-0x10(%rbp)
jne    117d <skip_loop+0x6d>
cmpl   $0x0,-0xc(%rbp)
jne    116f <skip_loop+0x5f>
jmp    1187 <skip_loop+0x77>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    117d <skip_loop+0x6d>
jmp    1182 <skip_loop+0x72>
jmp    1123 <skip_loop+0x13>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<skip_loop>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1030 <fgetc@plt>
mov    0x2ec5(%rip),%r14
cmp    (%r14),%eax
jne    112d <skip_loop+0x1d>
pop    %rbx
pop    %r14
pop    %rbp
ret
xor    %ebp,%ebp
jmp    114d <skip_loop+0x3d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <fgetc@plt>
cmp    (%r14),%eax
je     1128 <skip_loop+0x18>
cmp    $0x5d,%eax
je     1160 <skip_loop+0x50>
cmp    $0x5b,%eax
jne    1140 <skip_loop+0x30>
add    $0x1,%ebp
jmp    1140 <skip_loop+0x30>
nopl   0x0(%rax)
test   %ebp,%ebp
je     1128 <skip_loop+0x18>
add    $0xffffffff,%ebp
jmp    1140 <skip_loop+0x30>

LLVM IR (-O0):
@EOF = global i32 0
define void @skip_loop(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
store i32* %0, i32** %2
store i32 0, i32* %3
br label %5
5: ; preds = %28, %1
%6 = load i32*, i32** %2
%7 = call i32 @fgetc(i32* %6)
store i32 %7, i32* %4
%8 = load i32, i32* @EOF
%9 = icmp ne i32 %7, %8
br i1 %9, label %10, label %29
10: ; preds = %5
%11 = load i32, i32* %4
%12 = icmp eq i32 %11, 91
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = load i32, i32* %3
%15 = add nsw i32 %14, 1
store i32 %15, i32* %3
br label %28
16: ; preds = %10
%17 = load i32, i32* %4
%18 = icmp eq i32 %17, 93
br i1 %18, label %19, label %27
19: ; preds = %16
%20 = load i32, i32* %3
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %19
br label %29
23: ; preds = %19
%24 = load i32, i32* %3
%25 = add nsw i32 %24, -1
store i32 %25, i32* %3
br label %26
26: ; preds = %23
br label %27
27: ; preds = %26, %16
br label %28
28: ; preds = %27, %13
br label %5
29: ; preds = %22, %5
ret void
}

LLVM IR (-O2):
@EOF = global i32 0
define void @skip_loop(i32* nocapture %0) {
%2 = tail call i32 @fgetc(i32* %0)
%3 = load i32, i32* @EOF
%4 = icmp eq i32 %2, %3
br i1 %4, label %19, label %5
5: ; preds = %1, %14
%6 = phi i32 [ %16, %14 ], [ %2, %1 ]
%7 = phi i32 [ %15, %14 ], [ 0, %1 ]
switch i32 %6, label %14 [
i32 91, label %8
i32 93, label %10
]
8: ; preds = %5
%9 = add nsw i32 %7, 1
br label %14
10: ; preds = %5
%11 = icmp eq i32 %7, 0
br i1 %11, label %19, label %12
12: ; preds = %10
%13 = add nsw i32 %7, -1
br label %14
14: ; preds = %5, %12, %8
%15 = phi i32 [ %9, %8 ], [ %13, %12 ], [ %7, %5 ]
%16 = tail call i32 @fgetc(i32* %0)
%17 = load i32, i32* @EOF
%18 = icmp eq i32 %16, %17
br i1 %18, label %19, label %5
19: ; preds = %14, %10, %1
ret void
}