#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 */
struct ui {
  int dummy;
};
struct ss_ts {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ pop_tag(struct ss_ts *, int *, void *);
int /*<<< orphan*/ ui_get_c(struct ui *, int /*<<< orphan*/ *);
scalar_t__ ui_peek_c(struct ui *, char *);
void handle_pops(struct ui *is, void *context, struct ss_ts *ts, int *alt_ts) {
  char tmp;
  while (ui_peek_c(is, &tmp) && tmp == '}') {
    pop_tag(ts, alt_ts, context);
    ui_get_c(is, NULL);
  }
}


x86 assembly (clang, -O0):
<handle_pops>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x21(%rbp),%rsi
call   1030 <ui_peek_c@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x22(%rbp)
je     1174 <handle_pops+0x44>
movsbl -0x21(%rbp),%eax
cmp    $0x7d,%eax
sete   %al
mov    %al,-0x22(%rbp)
mov    -0x22(%rbp),%al
test   $0x1,%al
jne    1184 <handle_pops+0x54>
jmp    11a7 <handle_pops+0x77>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1040 <pop_tag@plt>
mov    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <ui_get_c@plt>
jmp    1148 <handle_pops+0x18>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle_pops>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
lea    0xf(%rsp),%rsi
call   1030 <ui_peek_c@plt>
test   %rax,%rax
je     119f <handle_pops+0x6f>
cmpb   $0x7d,0xf(%rsp)
jne    119f <handle_pops+0x6f>
lea    0xf(%rsp),%r13
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
call   1040 <pop_tag@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <ui_get_c@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1030 <ui_peek_c@plt>
test   %rax,%rax
je     119f <handle_pops+0x6f>
cmpb   $0x7d,0xf(%rsp)
je     1170 <handle_pops+0x40>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.ui = type { i32 }
%struct.ss_ts = type { i32 }
define void @handle_pops(%struct.ui* %0, i8* %1, %struct.ss_ts* %2, i32* %3) {
%5 = alloca %struct.ui*
%6 = alloca i8*
%7 = alloca %struct.ss_ts*
%8 = alloca i32*
%9 = alloca i8
store %struct.ui* %0, %struct.ui** %5
store i8* %1, i8** %6
store %struct.ss_ts* %2, %struct.ss_ts** %7
store i32* %3, i32** %8
br label %10
10: ; preds = %20, %4
%11 = load %struct.ui*, %struct.ui** %5
%12 = call i64 @ui_peek_c(%struct.ui* %11, i8* %9)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %10
%15 = load i8, i8* %9
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 125
br label %18
18: ; preds = %14, %10
%19 = phi i1 [ false, %10 ], [ %17, %14 ]
br i1 %19, label %20, label %27
20: ; preds = %18
%21 = load %struct.ss_ts*, %struct.ss_ts** %7
%22 = load i32*, i32** %8
%23 = load i8*, i8** %6
%24 = call i32 @pop_tag(%struct.ss_ts* %21, i32* %22, i8* %23)
%25 = load %struct.ui*, %struct.ui** %5
%26 = call i32 @ui_get_c(%struct.ui* %25, i32* null)
br label %10
27: ; preds = %18
ret void
}

LLVM IR (-O2):
%struct.ui = type { i32 }
%struct.ss_ts = type { i32 }
define void @handle_pops(%struct.ui* %0, i8* %1, %struct.ss_ts* %2, i32* %3) {
%5 = alloca i8
%6 = call i64 @ui_peek_c(%struct.ui* %0, i8* %5)
%7 = icmp ne i64 %6, 0
%8 = load i8, i8* %5
%9 = icmp eq i8 %8, 125
%10 = select i1 %7, i1 %9, i1 false
br i1 %10, label %11, label %19
11: ; preds = %4, %11
%12 = call i32 @pop_tag(%struct.ss_ts* %2, i32* %3, i8* %1)
%13 = call i32 @ui_get_c(%struct.ui* %0, i32* null)
%14 = call i64 @ui_peek_c(%struct.ui* %0, i8* %5)
%15 = icmp ne i64 %14, 0
%16 = load i8, i8* %5
%17 = icmp eq i8 %16, 125
%18 = select i1 %15, i1 %17, i1 false
br i1 %18, label %11, label %19
19: ; preds = %11, %4
ret void
}