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

/* Variables and functions */
int cpn_cfg_parse_string(struct cpn_cfg *, char *, size_t);
int map_file(char **, size_t *, char const *);
int /*<<< orphan*/ munmap(char *, size_t);
int cpn_cfg_parse(struct cpn_cfg *c, const char *path) {
  char *ptr;
  size_t len;
  int ret;
  ret = map_file(&ptr, &len, path);
  if (ret < 0) {
    return ret;
  }
  ret = cpn_cfg_parse_string(c, ptr, len);
  munmap(ptr, len);
  return ret;
}


x86 assembly (clang, -O0):
<cpn_cfg_parse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1030 <map_file@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    1169 <cpn_cfg_parse+0x39>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1190 <cpn_cfg_parse+0x60>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1040 <cpn_cfg_parse_string@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1050 <munmap@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cpn_cfg_parse>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rdx
mov    %rdi,%r14
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1030 <map_file@plt>
test   %eax,%eax
js     1175 <cpn_cfg_parse+0x45>
mov    0x10(%rsp),%rsi
mov    0x8(%rsp),%rdx
mov    %r14,%rdi
call   1040 <cpn_cfg_parse_string@plt>
mov    %eax,%ebx
mov    0x10(%rsp),%rdi
mov    0x8(%rsp),%rsi
call   1050 <munmap@plt>
jmp    1177 <cpn_cfg_parse+0x47>
mov    %eax,%ebx
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.cpn_cfg = type { i32 }
define i32 @cpn_cfg_parse(%struct.cpn_cfg* %0, i8* %1) {
%3 = alloca i32
%4 = alloca %struct.cpn_cfg*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
store %struct.cpn_cfg* %0, %struct.cpn_cfg** %4
store i8* %1, i8** %5
%9 = load i8*, i8** %5
%10 = call i32 @map_file(i8** %6, i64* %7, i8* %9)
store i32 %10, i32* %8
%11 = load i32, i32* %8
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = load i32, i32* %8
store i32 %14, i32* %3
br label %24
15: ; preds = %2
%16 = load %struct.cpn_cfg*, %struct.cpn_cfg** %4
%17 = load i8*, i8** %6
%18 = load i64, i64* %7
%19 = call i32 @cpn_cfg_parse_string(%struct.cpn_cfg* %16, i8* %17, i64 %18)
store i32 %19, i32* %8
%20 = load i8*, i8** %6
%21 = load i64, i64* %7
%22 = call i32 @munmap(i8* %20, i64 %21)
%23 = load i32, i32* %8
store i32 %23, i32* %3
br label %24
24: ; preds = %15, %13
%25 = load i32, i32* %3
ret i32 %25
}

LLVM IR (-O2):
%struct.cpn_cfg = type { i32 }
define i32 @cpn_cfg_parse(%struct.cpn_cfg* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = bitcast i8** %3 to i8*
%6 = bitcast i64* %4 to i8*
%7 = call i32 @map_file(i8** %3, i64* %4, i8* %1)
%8 = icmp slt i32 %7, 0
br i1 %8, label %16, label %9
9: ; preds = %2
%10 = load i8*, i8** %3
%11 = load i64, i64* %4
%12 = call i32 @cpn_cfg_parse_string(%struct.cpn_cfg* %0, i8* %10, i64 %11)
%13 = load i8*, i8** %3
%14 = load i64, i64* %4
%15 = call i32 @munmap(i8* %13, i64 %14)
br label %16
16: ; preds = %2, %9
%17 = phi i32 [ %12, %9 ], [ %7, %2 ]
ret i32 %17
}