#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 mapch(char);
int /*<<< orphan*/ number(int);
int /*<<< orphan*/ xwrite(char);
getstr() {
  auto i, c, d;
  i = 1;
loop:
  if ((c = mapch('"')) < 0) {
    number(2048);
    xwrite('\n');
    return (i);
  }
  if ((d = mapch('"')) < 0) {
    number(c * 512 + 4);
    xwrite('\n');
    return (i);
  }
  number(c * 512 + d);
  xwrite('\n');
  i = i + 1;
  goto loop;
}


x86 assembly (clang, -O0):
<getstr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x1,-0x8(%rbp)
mov    $0x22,%edi
call   1040 <mapch@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jge    1174 <getstr+0x44>
mov    $0x800,%edi
call   1050 <number@plt>
mov    $0xa,%edi
call   1030 <xwrite@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11d3 <getstr+0xa3>
mov    $0x22,%edi
call   1040 <mapch@plt>
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
jge    11ad <getstr+0x7d>
mov    -0xc(%rbp),%edi
shl    $0x9,%edi
add    $0x4,%edi
call   1050 <number@plt>
mov    $0xa,%edi
call   1030 <xwrite@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11d3 <getstr+0xa3>
mov    -0xc(%rbp),%edi
shl    $0x9,%edi
add    -0x10(%rbp),%edi
call   1050 <number@plt>
mov    $0xa,%edi
call   1030 <xwrite@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    113f <getstr+0xf>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getstr>:
push   %rbp
push   %r14
push   %rbx
mov    $0x22,%edi
call   1040 <mapch@plt>
mov    $0x800,%r14d
test   %eax,%eax
js     1189 <getstr+0x59>
mov    %eax,%ebp
mov    $0x1,%ebx
nop
mov    $0x22,%edi
call   1040 <mapch@plt>
shl    $0x9,%ebp
test   %eax,%eax
js     1190 <getstr+0x60>
add    %ebp,%eax
mov    %eax,%edi
call   1050 <number@plt>
mov    $0xa,%edi
call   1030 <xwrite@plt>
add    $0x1,%ebx
mov    $0x22,%edi
call   1040 <mapch@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    1150 <getstr+0x20>
jmp    1196 <getstr+0x66>
mov    $0x1,%ebx
jmp    1196 <getstr+0x66>
or     $0x4,%ebp
mov    %ebp,%r14d
mov    %r14d,%edi
call   1050 <number@plt>
mov    $0xa,%edi
call   1030 <xwrite@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @getstr() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 1, i32* %2
br label %5
5: ; preds = %22, %0
%6 = call i32 @mapch(i8 signext 34)
store i32 %6, i32* %3
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %5
%9 = call i32 @number(i32 2048)
%10 = call i32 @xwrite(i8 signext 10)
%11 = load i32, i32* %2
store i32 %11, i32* %1
br label %31
12: ; preds = %5
%13 = call i32 @mapch(i8 signext 34)
store i32 %13, i32* %4
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %22
15: ; preds = %12
%16 = load i32, i32* %3
%17 = mul nsw i32 %16, 512
%18 = add nsw i32 %17, 4
%19 = call i32 @number(i32 %18)
%20 = call i32 @xwrite(i8 signext 10)
%21 = load i32, i32* %2
store i32 %21, i32* %1
br label %31
22: ; preds = %12
%23 = load i32, i32* %3
%24 = mul nsw i32 %23, 512
%25 = load i32, i32* %4
%26 = add nsw i32 %24, %25
%27 = call i32 @number(i32 %26)
%28 = call i32 @xwrite(i8 signext 10)
%29 = load i32, i32* %2
%30 = add nsw i32 %29, 1
store i32 %30, i32* %2
br label %5
31: ; preds = %15, %8
%32 = load i32, i32* %1
ret i32 %32
}

LLVM IR (-O2):
define i32 @getstr() {
%1 = tail call i32 @mapch(i8 signext 34)
%2 = icmp slt i32 %1, 0
br i1 %2, label %18, label %3
3: ; preds = %0, %11
%4 = phi i32 [ %16, %11 ], [ %1, %0 ]
%5 = phi i32 [ %15, %11 ], [ 1, %0 ]
%6 = tail call i32 @mapch(i8 signext 34)
%7 = icmp slt i32 %6, 0
%8 = shl nsw i32 %4, 9
br i1 %7, label %9, label %11
9: ; preds = %3
%10 = or i32 %8, 4
br label %18
11: ; preds = %3
%12 = add nsw i32 %6, %8
%13 = tail call i32 @number(i32 %12)
%14 = tail call i32 @xwrite(i8 signext 10)
%15 = add nuw nsw i32 %5, 1
%16 = tail call i32 @mapch(i8 signext 34)
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %3
18: ; preds = %11, %0, %9
%19 = phi i32 [ %10, %9 ], [ 2048, %0 ], [ 2048, %11 ]
%20 = phi i32 [ %5, %9 ], [ 1, %0 ], [ %15, %11 ]
%21 = tail call i32 @number(i32 %19)
%22 = tail call i32 @xwrite(i8 signext 10)
ret i32 %20
}