#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 printf_format {
  int dummy;
};

/* Variables and functions */
scalar_t__ _os_assert(char *, char *, char *);
scalar_t__ get_flags(struct printf_format *, char const *);
int get_length_and_specifier(struct printf_format *, char const *);
int get_precision(struct printf_format *, char const *);
int get_width(struct printf_format *, char const *);
int get_format(struct printf_format *format, const char *str) {
  int i = 0;
  i += get_flags(format, &str[i]);
  (void)((i != -1) ||
         _os_assert("i != -1",
                    "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                    "outputs/2022-01-22/02-19-57/repos/RichardHScott/os_c/refs/"
                    "heads/master/src/terminal.c",
                    "342"));
  int ret = get_width(format, &str[i]);
  (void)((ret != -1) ||
         _os_assert("ret != -1",
                    "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                    "outputs/2022-01-22/02-19-57/repos/RichardHScott/os_c/refs/"
                    "heads/master/src/terminal.c",
                    "345"));
  i += ret;
  ret = get_precision(format, &str[i]);
  (void)((ret != -1) ||
         _os_assert("ret != -1",
                    "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                    "outputs/2022-01-22/02-19-57/repos/RichardHScott/os_c/refs/"
                    "heads/master/src/terminal.c",
                    "349"));
  i += ret;
  ret = get_length_and_specifier(format, &str[i]);
  (void)((ret != -1) ||
         _os_assert("ret != -1",
                    "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                    "outputs/2022-01-22/02-19-57/repos/RichardHScott/os_c/refs/"
                    "heads/master/src/terminal.c",
                    "353"));
  i += ret;
  return i;
}


x86 assembly (clang, -O0):
<get_format>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movslq -0x14(%rbp),%rax
add    %rax,%rsi
call   1070 <get_flags@plt>
mov    %rax,%rcx
movslq -0x14(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x14(%rbp)
mov    $0x1,%al
cmpl   $0xffffffff,-0x14(%rbp)
mov    %al,-0x19(%rbp)
jne    11bb <get_format+0x6b>
lea    0xe62(%rip),%rdi
lea    0xe63(%rip),%rsi
lea    0xeea(%rip),%rdx
call   1030 <_os_assert@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movslq -0x14(%rbp),%rax
add    %rax,%rsi
call   1050 <get_width@plt>
mov    %eax,-0x18(%rbp)
mov    $0x1,%al
cmpl   $0xffffffff,-0x18(%rbp)
mov    %al,-0x1a(%rbp)
jne    1208 <get_format+0xb8>
lea    0xeaf(%rip),%rdi
lea    0xe16(%rip),%rsi
lea    0xeab(%rip),%rdx
call   1030 <_os_assert@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x1a(%rbp)
mov    -0x1a(%rbp),%al
mov    -0x18(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movslq -0x14(%rbp),%rax
add    %rax,%rsi
call   1060 <get_precision@plt>
mov    %eax,-0x18(%rbp)
mov    $0x1,%al
cmpl   $0xffffffff,-0x18(%rbp)
mov    %al,-0x1b(%rbp)
jne    125e <get_format+0x10e>
lea    0xe59(%rip),%rdi
lea    0xdc0(%rip),%rsi
lea    0xe59(%rip),%rdx
call   1030 <_os_assert@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x1b(%rbp)
mov    -0x1b(%rbp),%al
mov    -0x18(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movslq -0x14(%rbp),%rax
add    %rax,%rsi
call   1040 <get_length_and_specifier@plt>
mov    %eax,-0x18(%rbp)
mov    $0x1,%al
cmpl   $0xffffffff,-0x18(%rbp)
mov    %al,-0x1c(%rbp)
jne    12b4 <get_format+0x164>
lea    0xe03(%rip),%rdi
lea    0xd6a(%rip),%rsi
lea    0xe07(%rip),%rdx
call   1030 <_os_assert@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x1c(%rbp)
mov    -0x1c(%rbp),%al
mov    -0x18(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_format>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r12
mov    %rdi,%r14
call   1070 <get_flags@plt>
mov    %rax,%r15
cmp    $0xffffffff,%r15d
jne    1186 <get_format+0x36>
lea    0xe8d(%rip),%rdi
lea    0xe8e(%rip),%rsi
lea    0xf15(%rip),%rdx
call   1030 <_os_assert@plt>
movslq %r15d,%rsi
add    %r12,%rsi
mov    %r14,%rdi
call   1050 <get_width@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
jne    11b5 <get_format+0x65>
lea    0xef8(%rip),%rdi
lea    0xe5f(%rip),%rsi
lea    0xef4(%rip),%rdx
call   1030 <_os_assert@plt>
add    %r15d,%ebp
movslq %ebp,%rsi
add    %r12,%rsi
mov    %r14,%rdi
call   1060 <get_precision@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
jne    11e7 <get_format+0x97>
lea    0xec6(%rip),%rdi
lea    0xe2d(%rip),%rsi
lea    0xec6(%rip),%rdx
call   1030 <_os_assert@plt>
add    %ebp,%ebx
movslq %ebx,%rax
add    %rax,%r12
mov    %r14,%rdi
mov    %r12,%rsi
call   1040 <get_length_and_specifier@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
jne    121b <get_format+0xcb>
lea    0xe92(%rip),%rdi
lea    0xdf9(%rip),%rsi
lea    0xe96(%rip),%rdx
call   1030 <_os_assert@plt>
add    %ebx,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.printf_format = type { i32 }
@.str = [8 x i8] c"i != -1\00"
@.str.1 = [142 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/RichardHScott/os_c/refs/heads/master/src/terminal.c\00"
@.str.2 = [4 x i8] c"342\00"
@.str.3 = [10 x i8] c"ret != -1\00"
@.str.4 = [4 x i8] c"345\00"
@.str.5 = [4 x i8] c"349\00"
@.str.6 = [4 x i8] c"353\00"
define i32 @get_format(%struct.printf_format* %0, i8* %1) {
%3 = alloca %struct.printf_format*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store %struct.printf_format* %0, %struct.printf_format** %3
store i8* %1, i8** %4
store i32 0, i32* %5
%7 = load %struct.printf_format*, %struct.printf_format** %3
%8 = load i8*, i8** %4
%9 = load i32, i32* %5
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %8, i64 %10
%12 = call i64 @get_flags(%struct.printf_format* %7, i8* %11)
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = add nsw i64 %14, %12
%16 = trunc i64 %15 to i32
store i32 %16, i32* %5
%17 = load i32, i32* %5
%18 = icmp ne i32 %17, -1
br i1 %18, label %22, label %19
19: ; preds = %2
%20 = call i64 @_os_assert(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([142 x i8], [142 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp ne i64 %20, 0
br label %22
22: ; preds = %19, %2
%23 = phi i1 [ true, %2 ], [ %21, %19 ]
%24 = zext i1 %23 to i32
%25 = load %struct.printf_format*, %struct.printf_format** %3
%26 = load i8*, i8** %4
%27 = load i32, i32* %5
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
%30 = call i32 @get_width(%struct.printf_format* %25, i8* %29)
store i32 %30, i32* %6
%31 = load i32, i32* %6
%32 = icmp ne i32 %31, -1
br i1 %32, label %36, label %33
33: ; preds = %22
%34 = call i64 @_os_assert(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([142 x i8], [142 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%35 = icmp ne i64 %34, 0
br label %36
36: ; preds = %33, %22
%37 = phi i1 [ true, %22 ], [ %35, %33 ]
%38 = zext i1 %37 to i32
%39 = load i32, i32* %6
%40 = load i32, i32* %5
%41 = add nsw i32 %40, %39
store i32 %41, i32* %5
%42 = load %struct.printf_format*, %struct.printf_format** %3
%43 = load i8*, i8** %4
%44 = load i32, i32* %5
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %43, i64 %45
%47 = call i32 @get_precision(%struct.printf_format* %42, i8* %46)
store i32 %47, i32* %6
%48 = load i32, i32* %6
%49 = icmp ne i32 %48, -1
br i1 %49, label %53, label %50
50: ; preds = %36
%51 = call i64 @_os_assert(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([142 x i8], [142 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%52 = icmp ne i64 %51, 0
br label %53
53: ; preds = %50, %36
%54 = phi i1 [ true, %36 ], [ %52, %50 ]
%55 = zext i1 %54 to i32
%56 = load i32, i32* %6
%57 = load i32, i32* %5
%58 = add nsw i32 %57, %56
store i32 %58, i32* %5
%59 = load %struct.printf_format*, %struct.printf_format** %3
%60 = load i8*, i8** %4
%61 = load i32, i32* %5
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i8, i8* %60, i64 %62
%64 = call i32 @get_length_and_specifier(%struct.printf_format* %59, i8* %63)
store i32 %64, i32* %6
%65 = load i32, i32* %6
%66 = icmp ne i32 %65, -1
br i1 %66, label %70, label %67
67: ; preds = %53
%68 = call i64 @_os_assert(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([142 x i8], [142 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%69 = icmp ne i64 %68, 0
br label %70
70: ; preds = %67, %53
%71 = phi i1 [ true, %53 ], [ %69, %67 ]
%72 = zext i1 %71 to i32
%73 = load i32, i32* %6
%74 = load i32, i32* %5
%75 = add nsw i32 %74, %73
store i32 %75, i32* %5
%76 = load i32, i32* %5
ret i32 %76
}

LLVM IR (-O2):
%struct.printf_format = type { i32 }
@.str = [8 x i8] c"i != -1\00"
@.str.1 = [142 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/RichardHScott/os_c/refs/heads/master/src/terminal.c\00"
@.str.2 = [4 x i8] c"342\00"
@.str.3 = [10 x i8] c"ret != -1\00"
@.str.4 = [4 x i8] c"345\00"
@.str.5 = [4 x i8] c"349\00"
@.str.6 = [4 x i8] c"353\00"
define i32 @get_format(%struct.printf_format* %0, i8* %1) {
%3 = tail call i64 @get_flags(%struct.printf_format* %0, i8* %1)
%4 = trunc i64 %3 to i32
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i64 @_os_assert(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([142 x i8], [142 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %8
8: ; preds = %6, %2
%9 = shl i64 %3, 32
%10 = ashr exact i64 %9, 32
%11 = getelementptr inbounds i8, i8* %1, i64 %10
%12 = tail call i32 @get_width(%struct.printf_format* %0, i8* %11)
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %16
14: ; preds = %8
%15 = tail call i64 @_os_assert(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([142 x i8], [142 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %16
16: ; preds = %14, %8
%17 = add nsw i32 %12, %4
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %1, i64 %18
%20 = tail call i32 @get_precision(%struct.printf_format* %0, i8* %19)
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %24
22: ; preds = %16
%23 = tail call i64 @_os_assert(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([142 x i8], [142 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
br label %24
24: ; preds = %22, %16
%25 = add nsw i32 %20, %17
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %1, i64 %26
%28 = tail call i32 @get_length_and_specifier(%struct.printf_format* %0, i8* %27)
%29 = icmp eq i32 %28, -1
br i1 %29, label %30, label %32
30: ; preds = %24
%31 = tail call i64 @_os_assert(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([142 x i8], [142 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
br label %32
32: ; preds = %30, %24
%33 = add nsw i32 %28, %25
ret i32 %33
}