#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*/ internal_logit(char *, int, char *, char *, int, int const);
int /*<<< orphan*/ strncasecmp(char const *, char *, int);
long strtol(char const *, char **, int);
int xround(int const);
const char *parse_layout_coordinate(const char *fmt, int *val, const int max) {
  long v;
  const char *e = fmt;
  if (!strncasecmp(fmt, "FILL", sizeof("FILL") - 1)) {
    *val = (-1);
    e += sizeof("FILL") - 1;
  } else {
    v = strtol(fmt, (char **)&e, 10);
    if (e == fmt)
      return NULL;
    if (*e == '%') {
      *val = xround(max * v / 100.0);
      e++;
    } else
      *val = v;
    if (*val < 0 || *val > max) {
      internal_logit("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                     "outputs/2022-01-22/02-19-57/repos/ecthiender/mocp-git/"
                     "refs/heads/master/interface_elements.c",
                     782, "UNKNOWN_FUNC",
                     "Coordinate out of range - %d is not in (0, %d)", *val,
                     max);
      return NULL;
    }
  }
  if (*e == ',')
    e++;
  return e;
}


x86 assembly (clang, -O0):
<parse_layout_coordinate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea2(%rip),%rsi
mov    $0x4,%edx
call   1050 <strncasecmp@plt>
cmp    $0x0,%eax
jne    1194 <parse_layout_coordinate+0x54>
mov    -0x18(%rbp),%rax
movl   $0xffffffff,(%rax)
mov    -0x30(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x30(%rbp)
jmp    1275 <parse_layout_coordinate+0x135>
mov    -0x10(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %rax,-0x28(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x10(%rbp),%rax
jne    11c5 <parse_layout_coordinate+0x85>
movq   $0x0,-0x8(%rbp)
jmp    1299 <parse_layout_coordinate+0x159>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x25,%eax
jne    1211 <parse_layout_coordinate+0xd1>
movslq -0x1c(%rbp),%rax
imul   -0x28(%rbp),%rax
cvtsi2sd %rax,%xmm0
movsd  0xe15(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <xround@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    121d <parse_layout_coordinate+0xdd>
mov    -0x28(%rbp),%rax
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
jl     1239 <parse_layout_coordinate+0xf9>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
cmp    -0x1c(%rbp),%eax
jle    1270 <parse_layout_coordinate+0x130>
mov    -0x18(%rbp),%rax
mov    (%rax),%r8d
mov    -0x1c(%rbp),%r9d
lea    0xdc2(%rip),%rdi
mov    $0x30e,%esi
lea    0xe4b(%rip),%rdx
lea    0xe51(%rip),%rcx
call   1060 <internal_logit@plt>
movq   $0x0,-0x8(%rbp)
jmp    1299 <parse_layout_coordinate+0x159>
jmp    1275 <parse_layout_coordinate+0x135>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2c,%eax
jne    1291 <parse_layout_coordinate+0x151>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_layout_coordinate>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%r15
mov    %rdi,%rbp
mov    %rdi,(%rsp)
lea    0xead(%rip),%rsi
mov    $0x4,%edx
call   1050 <strncasecmp@plt>
test   %eax,%eax
je     11b9 <parse_layout_coordinate+0x79>
mov    %rsp,%rsi
mov    %rbp,%rdi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    (%rsp),%rbx
cmp    %rbp,%rbx
je     120b <parse_layout_coordinate+0xcb>
cmpb   $0x25,(%rbx)
jne    11cd <parse_layout_coordinate+0x8d>
movslq %r14d,%rcx
imul   %rcx,%rax
cvtsi2sd %rax,%xmm0
divsd  0xe61(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <xround@plt>
mov    %eax,(%r15)
add    $0x1,%rbx
mov    %rbx,(%rsp)
test   %eax,%eax
jns    11d4 <parse_layout_coordinate+0x94>
jmp    11e6 <parse_layout_coordinate+0xa6>
movl   $0xffffffff,(%r15)
add    $0x4,%rbp
mov    %rbp,(%rsp)
mov    %rbp,%rbx
jmp    11d9 <parse_layout_coordinate+0x99>
mov    %eax,(%r15)
test   %eax,%eax
js     11e6 <parse_layout_coordinate+0xa6>
cmp    %r14d,%eax
jg     11e6 <parse_layout_coordinate+0xa6>
xor    %eax,%eax
cmpb   $0x2c,(%rbx)
sete   %al
add    %rbx,%rax
jmp    120d <parse_layout_coordinate+0xcd>
lea    0xe20(%rip),%rdi
lea    0xeae(%rip),%rdx
lea    0xeb4(%rip),%rcx
mov    $0x30e,%esi
mov    %eax,%r8d
mov    %r14d,%r9d
call   1060 <internal_logit@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"FILL\00"
@.str.1 = [149 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ecthiender/mocp-git/refs/heads/master/interface_elements.c\00"
@.str.2 = [13 x i8] c"UNKNOWN_FUNC\00"
@.str.3 = [47 x i8] c"Coordinate out of range - %d is not in (0, %d)\00"
define i8* @parse_layout_coordinate(i8* %0, i32* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i64
%9 = alloca i8*
store i8* %0, i8** %5
store i32* %1, i32** %6
store i32 %2, i32* %7
%10 = load i8*, i8** %5
store i8* %10, i8** %9
%11 = load i8*, i8** %5
%12 = call i32 @strncasecmp(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%13 = icmp ne i32 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %3
%15 = load i32*, i32** %6
store i32 -1, i32* %15
%16 = load i8*, i8** %9
%17 = getelementptr inbounds i8, i8* %16, i64 4
store i8* %17, i8** %9
br label %61
18: ; preds = %3
%19 = load i8*, i8** %5
%20 = call i64 @strtol(i8* %19, i8** %9, i32 10)
store i64 %20, i64* %8
%21 = load i8*, i8** %9
%22 = load i8*, i8** %5
%23 = icmp eq i8* %21, %22
br i1 %23, label %24, label %25
24: ; preds = %18
store i8* null, i8** %4
br label %71
25: ; preds = %18
%26 = load i8*, i8** %9
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 37
br i1 %29, label %30, label %42
30: ; preds = %25
%31 = load i32, i32* %7
%32 = sext i32 %31 to i64
%33 = load i64, i64* %8
%34 = mul nsw i64 %32, %33
%35 = sitofp i64 %34 to double
%36 = fdiv double %35, 1.000000e+02
%37 = fptosi double %36 to i32
%38 = call i32 @xround(i32 %37)
%39 = load i32*, i32** %6
store i32 %38, i32* %39
%40 = load i8*, i8** %9
%41 = getelementptr inbounds i8, i8* %40, i32 1
store i8* %41, i8** %9
br label %46
42: ; preds = %25
%43 = load i64, i64* %8
%44 = trunc i64 %43 to i32
%45 = load i32*, i32** %6
store i32 %44, i32* %45
br label %46
46: ; preds = %42, %30
%47 = load i32*, i32** %6
%48 = load i32, i32* %47
%49 = icmp slt i32 %48, 0
br i1 %49, label %55, label %50
50: ; preds = %46
%51 = load i32*, i32** %6
%52 = load i32, i32* %51
%53 = load i32, i32* %7
%54 = icmp sgt i32 %52, %53
br i1 %54, label %55, label %60
55: ; preds = %50, %46
%56 = load i32*, i32** %6
%57 = load i32, i32* %56
%58 = load i32, i32* %7
%59 = call i32 @internal_logit(i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.1, i64 0, i64 0), i32 782, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0), i32 %57, i32 %58)
store i8* null, i8** %4
br label %71
60: ; preds = %50
br label %61
61: ; preds = %60, %14
%62 = load i8*, i8** %9
%63 = load i8, i8* %62
%64 = sext i8 %63 to i32
%65 = icmp eq i32 %64, 44
br i1 %65, label %66, label %69
66: ; preds = %61
%67 = load i8*, i8** %9
%68 = getelementptr inbounds i8, i8* %67, i32 1
store i8* %68, i8** %9
br label %69
69: ; preds = %66, %61
%70 = load i8*, i8** %9
store i8* %70, i8** %4
br label %71
71: ; preds = %69, %55, %24
%72 = load i8*, i8** %4
ret i8* %72
}

LLVM IR (-O2):
@.str = [5 x i8] c"FILL\00"
@.str.1 = [149 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ecthiender/mocp-git/refs/heads/master/interface_elements.c\00"
@.str.2 = [13 x i8] c"UNKNOWN_FUNC\00"
@.str.3 = [47 x i8] c"Coordinate out of range - %d is not in (0, %d)\00"
define i8* @parse_layout_coordinate(i8* %0, i32* nocapture %1, i32 %2) {
%4 = alloca i8*
%5 = bitcast i8** %4 to i8*
store i8* %0, i8** %4
%6 = tail call i32 @strncasecmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %3
store i32 -1, i32* %1
%9 = getelementptr inbounds i8, i8* %0, i64 4
store i8* %9, i8** %4
br label %35
10: ; preds = %3
%11 = call i64 @strtol(i8* %0, i8** %4, i32 10)
%12 = load i8*, i8** %4
%13 = icmp eq i8* %12, %0
br i1 %13, label %41, label %14
14: ; preds = %10
%15 = load i8, i8* %12
%16 = icmp eq i8 %15, 37
br i1 %16, label %17, label %25
17: ; preds = %14
%18 = sext i32 %2 to i64
%19 = mul nsw i64 %11, %18
%20 = sitofp i64 %19 to double
%21 = fdiv double %20, 1.000000e+02
%22 = fptosi double %21 to i32
%23 = tail call i32 @xround(i32 %22)
store i32 %23, i32* %1
%24 = getelementptr inbounds i8, i8* %12, i64 1
store i8* %24, i8** %4
br label %27
25: ; preds = %14
%26 = trunc i64 %11 to i32
store i32 %26, i32* %1
br label %27
27: ; preds = %25, %17
%28 = phi i8* [ %12, %25 ], [ %24, %17 ]
%29 = phi i32 [ %26, %25 ], [ %23, %17 ]
%30 = icmp slt i32 %29, 0
%31 = icmp sgt i32 %29, %2
%32 = or i1 %30, %31
br i1 %32, label %33, label %35
33: ; preds = %27
%34 = tail call i32 @internal_logit(i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.1, i64 0, i64 0), i32 782, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0), i32 %29, i32 %2)
br label %41
35: ; preds = %27, %8
%36 = phi i8* [ %28, %27 ], [ %9, %8 ]
%37 = load i8, i8* %36
%38 = icmp eq i8 %37, 44
%39 = zext i1 %38 to i64
%40 = getelementptr i8, i8* %36, i64 %39
br label %41
41: ; preds = %35, %10, %33
%42 = phi i8* [ null, %33 ], [ null, %10 ], [ %40, %35 ]
ret i8* %42
}