#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);
int /*<<< orphan*/ ocr_log(int, char *, int, char *, size_t);
size_t string_size(const char *text) {
  assert(text[0] == '"');
  ++text;
  size_t size = 0;
  while (text && text[0] != '"') {
    ++size;
    ++text;
  }
  ocr_log(2,
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/oblivionsoftware/ocr/refs/heads/master/"
          "src/json.c",
          55, "text size: %zu", size);
  assert(text[0] == '"');
  return size;
}


x86 assembly (clang, -O0):
<string_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x8(%rbp)
mov    %al,-0x11(%rbp)
je     1177 <string_size+0x57>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1187 <string_size+0x67>
jmp    11a4 <string_size+0x84>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1157 <string_size+0x37>
mov    -0x10(%rbp),%r8
mov    $0x2,%edi
lea    0xe4c(%rip),%rsi
mov    $0x37,%edx
lea    0xecc(%rip),%rcx
call   1040 <ocr_log@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<string_size>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %edi,%edi
cmpb   $0x22,(%r14)
sete   %dil
call   1030 <assert@plt>
mov    $0xffffffffffffffff,%rbx
nopl   (%rax)
cmpb   $0x22,0x2(%r14,%rbx,1)
lea    0x1(%rbx),%rbx
jne    1140 <string_size+0x20>
lea    0xead(%rip),%rsi
lea    0xf32(%rip),%rcx
mov    $0x2,%edi
mov    $0x37,%edx
mov    %rbx,%r8
call   1040 <ocr_log@plt>
xor    %edi,%edi
cmpb   $0x22,0x1(%r14,%rbx,1)
sete   %dil
call   1030 <assert@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [140 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/oblivionsoftware/ocr/refs/heads/master/src/json.c\00"
@.str.1 = [15 x i8] c"text size: %zu\00"
define i64 @string_size(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = getelementptr inbounds i8, i8* %4, i64 0
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
%8 = icmp eq i32 %7, 34
%9 = zext i1 %8 to i32
%10 = call i32 @assert(i32 %9)
%11 = load i8*, i8** %2
%12 = getelementptr inbounds i8, i8* %11, i32 1
store i8* %12, i8** %2
store i64 0, i64* %3
br label %13
13: ; preds = %24, %1
%14 = load i8*, i8** %2
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %22
16: ; preds = %13
%17 = load i8*, i8** %2
%18 = getelementptr inbounds i8, i8* %17, i64 0
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 34
br label %22
22: ; preds = %16, %13
%23 = phi i1 [ false, %13 ], [ %21, %16 ]
br i1 %23, label %24, label %29
24: ; preds = %22
%25 = load i64, i64* %3
%26 = add i64 %25, 1
store i64 %26, i64* %3
%27 = load i8*, i8** %2
%28 = getelementptr inbounds i8, i8* %27, i32 1
store i8* %28, i8** %2
br label %13
29: ; preds = %22
%30 = load i64, i64* %3
%31 = call i32 @ocr_log(i32 2, i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str, i64 0, i64 0), i32 55, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i64 %30)
%32 = load i8*, i8** %2
%33 = getelementptr inbounds i8, i8* %32, i64 0
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 34
%37 = zext i1 %36 to i32
%38 = call i32 @assert(i32 %37)
%39 = load i64, i64* %3
ret i64 %39
}

LLVM IR (-O2):
@.str = [140 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/oblivionsoftware/ocr/refs/heads/master/src/json.c\00"
@.str.1 = [15 x i8] c"text size: %zu\00"
define i64 @string_size(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 34
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
br label %6
6: ; preds = %6, %1
%7 = phi i8* [ %0, %1 ], [ %9, %6 ]
%8 = phi i64 [ 0, %1 ], [ %12, %6 ]
%9 = getelementptr inbounds i8, i8* %7, i64 1
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 34
%12 = add i64 %8, 1
br i1 %11, label %13, label %6
13: ; preds = %6
%14 = tail call i32 @ocr_log(i32 2, i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str, i64 0, i64 0), i32 55, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i64 %8)
%15 = load i8, i8* %9
%16 = icmp eq i8 %15, 34
%17 = zext i1 %16 to i32
%18 = tail call i32 @assert(i32 %17)
ret i64 %8
}