#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 /*<<< orphan*/ assert(int /*<<< orphan*/);
void calc_box_size(int *size_x, int *size_y, char *content) {
  char *p;
  int i;
  assert(content != NULL);
  *size_x = 0;
  *size_y = 1;
  i = 0;
  p = content;
  while (*p != '\0') {
    if (*p == 0x01) {
      p += 2;
      continue;
    }
    if (*p == '\n') {
      (*size_y)++;
      i = 0;
    } else {
      i++;
      if (i > *size_x) {
        *size_x = i;
      }
    }
    p++;
  }
}


x86 assembly (clang, -O0):
<calc_box_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x8(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
movl   $0x0,-0x24(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11e8 <calc_box_size+0xd8>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x1,%eax
jne    118a <calc_box_size+0x7a>
mov    -0x20(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x20(%rbp)
jmp    1159 <calc_box_size+0x49>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    11b1 <calc_box_size+0xa1>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
movl   $0x0,-0x24(%rbp)
jmp    11d7 <calc_box_size+0xc7>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x8(%rbp),%rcx
cmp    (%rcx),%eax
jle    11d2 <calc_box_size+0xc2>
mov    -0x24(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
jmp    11d7 <calc_box_size+0xc7>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1159 <calc_box_size+0x49>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calc_box_size>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
xor    %edi,%edi
test   %rdx,%rdx
setne  %dil
call   1030 <assert@plt>
movl   $0x0,(%r15)
movl   $0x1,(%r14)
xor    %eax,%eax
add    $0x1,%rbx
movzbl -0x1(%rbx),%ecx
cmp    $0x1,%cl
jne    1150 <calc_box_size+0x40>
add    $0x2,%rbx
jmp    1140 <calc_box_size+0x30>
nop
test   %cl,%cl
je     1176 <calc_box_size+0x66>
cmp    $0xa,%cl
je     1170 <calc_box_size+0x60>
lea    0x1(%rax),%ecx
cmp    (%r15),%eax
mov    %ecx,%eax
jl     113c <calc_box_size+0x2c>
mov    %ecx,(%r15)
mov    %ecx,%eax
jmp    113c <calc_box_size+0x2c>
nopw   0x0(%rax,%rax,1)
addl   $0x1,(%r14)
jmp    113a <calc_box_size+0x2a>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @calc_box_size(i32* %0, i32* %1, i8* %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
store i8* %2, i8** %6
%9 = load i8*, i8** %6
%10 = icmp ne i8* %9, null
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = load i32*, i32** %4
store i32 0, i32* %13
%14 = load i32*, i32** %5
store i32 1, i32* %14
store i32 0, i32* %8
%15 = load i8*, i8** %6
store i8* %15, i8** %7
br label %16
16: ; preds = %49, %26, %3
%17 = load i8*, i8** %7
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %52
21: ; preds = %16
%22 = load i8*, i8** %7
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 1
br i1 %25, label %26, label %29
26: ; preds = %21
%27 = load i8*, i8** %7
%28 = getelementptr inbounds i8, i8* %27, i64 2
store i8* %28, i8** %7
br label %16
29: ; preds = %21
%30 = load i8*, i8** %7
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 10
br i1 %33, label %34, label %38
34: ; preds = %29
%35 = load i32*, i32** %5
%36 = load i32, i32* %35
%37 = add nsw i32 %36, 1
store i32 %37, i32* %35
store i32 0, i32* %8
br label %49
38: ; preds = %29
%39 = load i32, i32* %8
%40 = add nsw i32 %39, 1
store i32 %40, i32* %8
%41 = load i32, i32* %8
%42 = load i32*, i32** %4
%43 = load i32, i32* %42
%44 = icmp sgt i32 %41, %43
br i1 %44, label %45, label %48
45: ; preds = %38
%46 = load i32, i32* %8
%47 = load i32*, i32** %4
store i32 %46, i32* %47
br label %48
48: ; preds = %45, %38
br label %49
49: ; preds = %48, %34
%50 = load i8*, i8** %7
%51 = getelementptr inbounds i8, i8* %50, i32 1
store i8* %51, i8** %7
br label %16
52: ; preds = %16
ret void
}

LLVM IR (-O2):
define void @calc_box_size(i32* nocapture %0, i32* nocapture %1, i8* %2) {
%4 = icmp ne i8* %2, null
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
store i32 0, i32* %0
store i32 1, i32* %1
br label %7
7: ; preds = %23, %3
%8 = phi i8* [ %25, %23 ], [ %2, %3 ]
%9 = phi i32 [ %24, %23 ], [ 0, %3 ]
br label %10
10: ; preds = %7, %13
%11 = phi i8* [ %14, %13 ], [ %8, %7 ]
%12 = load i8, i8* %11
switch i8 %12, label %18 [
i8 0, label %26
i8 1, label %13
i8 10, label %15
]
13: ; preds = %10
%14 = getelementptr inbounds i8, i8* %11, i64 2
br label %10
15: ; preds = %10
%16 = load i32, i32* %1
%17 = add nsw i32 %16, 1
store i32 %17, i32* %1
br label %23
18: ; preds = %10
%19 = add nsw i32 %9, 1
%20 = load i32, i32* %0
%21 = icmp slt i32 %9, %20
br i1 %21, label %23, label %22
22: ; preds = %18
store i32 %19, i32* %0
br label %23
23: ; preds = %18, %22, %15
%24 = phi i32 [ 0, %15 ], [ %19, %22 ], [ %19, %18 ]
%25 = getelementptr inbounds i8, i8* %11, i64 1
br label %7
26: ; preds = %10
ret void
}