#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 */
scalar_t__ ceil(float);
int stb_easy_font_height(char *text) {
  float y = 0;
  int nonempty_line = 0;
  while (*text) {
    if (*text == '\n') {
      y += 12;
      nonempty_line = 0;
    } else {
      nonempty_line = 1;
    }
    ++text;
  }
  return (int)ceil(y + (nonempty_line ? 12 : 0));
}


x86 assembly (clang, -O0):
<stb_easy_font_height>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     117e <stb_easy_font_height+0x6e>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    1166 <stb_easy_font_height+0x56>
movss  0xeb0(%rip),%xmm0
addss  -0xc(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
jmp    116d <stb_easy_font_height+0x5d>
movl   $0x1,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    112b <stb_easy_font_height+0x1b>
movss  -0xc(%rbp),%xmm0
mov    -0x10(%rbp),%edx
xor    %eax,%eax
mov    $0xc,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
cvtsi2ss %eax,%xmm1
addss  %xmm1,%xmm0
call   1030 <ceil@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stb_easy_font_height>:
xor    %eax,%eax
xorps  %xmm0,%xmm0
movss  0xee3(%rip),%xmm1
jmp    112c <stb_easy_font_height+0x1c>
nop
addss  %xmm1,%xmm0
xor    %ecx,%ecx
add    $0x1,%rdi
mov    %ecx,%eax
movzbl (%rdi),%edx
cmp    $0xa,%dl
je     1120 <stb_easy_font_height+0x10>
mov    $0x1,%ecx
test   %dl,%dl
jne    1126 <stb_easy_font_height+0x16>
test   %eax,%eax
mov    $0xc,%ecx
cmove  %eax,%ecx
xorps  %xmm1,%xmm1
cvtsi2ss %ecx,%xmm1
addss  %xmm1,%xmm0
jmp    1030 <ceil@plt>

LLVM IR (-O0):
define i32 @stb_easy_font_height(i8* %0) {
%2 = alloca i8*
%3 = alloca float
%4 = alloca i32
store i8* %0, i8** %2
store float 0.000000e+00, float* %3
store i32 0, i32* %4
br label %5
5: ; preds = %18, %1
%6 = load i8*, i8** %2
%7 = load i8, i8* %6
%8 = icmp ne i8 %7, 0
br i1 %8, label %9, label %21
9: ; preds = %5
%10 = load i8*, i8** %2
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 10
br i1 %13, label %14, label %17
14: ; preds = %9
%15 = load float, float* %3
%16 = fadd float %15, 1.200000e+01
store float %16, float* %3
store i32 0, i32* %4
br label %18
17: ; preds = %9
store i32 1, i32* %4
br label %18
18: ; preds = %17, %14
%19 = load i8*, i8** %2
%20 = getelementptr inbounds i8, i8* %19, i32 1
store i8* %20, i8** %2
br label %5
21: ; preds = %5
%22 = load float, float* %3
%23 = load i32, i32* %4
%24 = icmp ne i32 %23, 0
%25 = zext i1 %24 to i64
%26 = select i1 %24, i32 12, i32 0
%27 = sitofp i32 %26 to float
%28 = fadd float %22, %27
%29 = call i64 @ceil(float %28)
%30 = trunc i64 %29 to i32
ret i32 %30
}

LLVM IR (-O2):
define i32 @stb_easy_font_height(i8* nocapture %0) {
br label %2
2: ; preds = %9, %1
%3 = phi i8* [ %0, %1 ], [ %12, %9 ]
%4 = phi float [ 0.000000e+00, %1 ], [ %10, %9 ]
%5 = phi i32 [ 0, %1 ], [ %11, %9 ]
%6 = load i8, i8* %3
switch i8 %6, label %9 [
i8 0, label %13
i8 10, label %7
]
7: ; preds = %2
%8 = fadd float %4, 1.200000e+01
br label %9
9: ; preds = %2, %7
%10 = phi float [ %8, %7 ], [ %4, %2 ]
%11 = phi i32 [ 0, %7 ], [ 1, %2 ]
%12 = getelementptr inbounds i8, i8* %3, i64 1
br label %2
13: ; preds = %2
%14 = icmp eq i32 %5, 0
%15 = select i1 %14, i32 0, i32 12
%16 = sitofp i32 %15 to float
%17 = fadd float %4, %16
%18 = tail call i64 @ceil(float %17)
%19 = trunc i64 %18 to i32
ret i32 %19
}