#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 lm {
  int dummy;
};
struct jsonElement {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ errAbort(char *, int, char *);
struct jsonElement *jsonParseExpressionLm(char *, int *, struct lm *);
int /*<<< orphan*/ skipLeadingSpacesWithPos(char *, int *);
struct jsonElement *jsonParseLm(char *str, struct lm *lm) {
  int pos = 0;
  struct jsonElement *ele = jsonParseExpressionLm(str, &pos, lm);
  skipLeadingSpacesWithPos(str, &pos);
  if (str[pos])
    errAbort("Invalid JSON: unprocessed trailing string at position: %d: %s",
             pos, str + pos);
  return ele;
}


x86 assembly (clang, -O0):
<jsonParseLm>:
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),%rdx
lea    -0x14(%rbp),%rsi
call   1050 <jsonParseExpressionLm@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <skipLeadingSpacesWithPos@plt>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     1195 <jsonParseLm+0x65>
mov    -0x14(%rbp),%esi
mov    -0x8(%rbp),%rdx
movslq -0x14(%rbp),%rax
add    %rax,%rdx
lea    0xe70(%rip),%rdi
call   1030 <errAbort@plt>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<jsonParseLm>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rdx
mov    %rdi,%rbx
movl   $0x0,0xc(%rsp)
lea    0xc(%rsp),%r15
mov    %r15,%rsi
call   1050 <jsonParseExpressionLm@plt>
mov    %rax,%r14
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <skipLeadingSpacesWithPos@plt>
movslq 0xc(%rsp),%rsi
cmpb   $0x0,(%rbx,%rsi,1)
je     117f <jsonParseLm+0x4f>
add    %rsi,%rbx
lea    0xe89(%rip),%rdi
mov    %rbx,%rdx
call   1030 <errAbort@plt>
mov    %r14,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.jsonElement = type { i32 }
%struct.lm = type { i32 }
@.str = [62 x i8] c"Invalid JSON: unprocessed trailing string at position: %d: %s\00"
define %struct.jsonElement* @jsonParseLm(i8* %0, %struct.lm* %1) {
%3 = alloca i8*
%4 = alloca %struct.lm*
%5 = alloca i32
%6 = alloca %struct.jsonElement*
store i8* %0, i8** %3
store %struct.lm* %1, %struct.lm** %4
store i32 0, i32* %5
%7 = load i8*, i8** %3
%8 = load %struct.lm*, %struct.lm** %4
%9 = call %struct.jsonElement* @jsonParseExpressionLm(i8* %7, i32* %5, %struct.lm* %8)
store %struct.jsonElement* %9, %struct.jsonElement** %6
%10 = load i8*, i8** %3
%11 = call i32 @skipLeadingSpacesWithPos(i8* %10, i32* %5)
%12 = load i8*, i8** %3
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8, i8* %15
%17 = icmp ne i8 %16, 0
br i1 %17, label %18, label %25
18: ; preds = %2
%19 = load i32, i32* %5
%20 = load i8*, i8** %3
%21 = load i32, i32* %5
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
%24 = call i32 @errAbort(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0), i32 %19, i8* %23)
br label %25
25: ; preds = %18, %2
%26 = load %struct.jsonElement*, %struct.jsonElement** %6
ret %struct.jsonElement* %26
}

LLVM IR (-O2):
%struct.jsonElement = type { i32 }
%struct.lm = type { i32 }
@.str = [62 x i8] c"Invalid JSON: unprocessed trailing string at position: %d: %s\00"
define %struct.jsonElement* @jsonParseLm(i8* %0, %struct.lm* %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%5 = call %struct.jsonElement* @jsonParseExpressionLm(i8* %0, i32* %3, %struct.lm* %1)
%6 = call i32 @skipLeadingSpacesWithPos(i8* %0, i32* %3)
%7 = load i32, i32* %3
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %0, i64 %8
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %2
%13 = call i32 @errAbort(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0), i32 %7, i8* %9)
br label %14
14: ; preds = %12, %2
ret %struct.jsonElement* %5
}