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

/* Variables and functions */
struct config_setting_t *
config_setting_get_elem(struct config_setting_t const *, int);
long long config_setting_get_int64(struct config_setting_t const *);
long long config_setting_get_int64_elem(const struct config_setting_t *vector,
                                        int idx) {
  const struct config_setting_t *element = config_setting_get_elem(vector, idx);
  return (element ? config_setting_get_int64(element) : 0);
}


x86 assembly (clang, -O0):
<config_setting_get_int64_elem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <config_setting_get_elem@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     115c <config_setting_get_int64_elem+0x3c>
mov    -0x18(%rbp),%rdi
call   1040 <config_setting_get_int64@plt>
mov    %rax,-0x20(%rbp)
jmp    1167 <config_setting_get_int64_elem+0x47>
xor    %eax,%eax
mov    %rax,-0x20(%rbp)
jmp    1167 <config_setting_get_int64_elem+0x47>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<config_setting_get_int64_elem>:
push   %rax
call   1030 <config_setting_get_elem@plt>
test   %rax,%rax
je     1134 <config_setting_get_int64_elem+0x14>
mov    %rax,%rdi
pop    %rax
jmp    1040 <config_setting_get_int64@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.config_setting_t = type { i32 }
define i64 @config_setting_get_int64_elem(%struct.config_setting_t* %0, i32 %1) {
%3 = alloca %struct.config_setting_t*
%4 = alloca i32
%5 = alloca %struct.config_setting_t*
store %struct.config_setting_t* %0, %struct.config_setting_t** %3
store i32 %1, i32* %4
%6 = load %struct.config_setting_t*, %struct.config_setting_t** %3
%7 = load i32, i32* %4
%8 = call %struct.config_setting_t* @config_setting_get_elem(%struct.config_setting_t* %6, i32 %7)
store %struct.config_setting_t* %8, %struct.config_setting_t** %5
%9 = load %struct.config_setting_t*, %struct.config_setting_t** %5
%10 = icmp ne %struct.config_setting_t* %9, null
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load %struct.config_setting_t*, %struct.config_setting_t** %5
%13 = call i64 @config_setting_get_int64(%struct.config_setting_t* %12)
br label %15
14: ; preds = %2
br label %15
15: ; preds = %14, %11
%16 = phi i64 [ %13, %11 ], [ 0, %14 ]
ret i64 %16
}

LLVM IR (-O2):
%struct.config_setting_t = type { i32 }
define i64 @config_setting_get_int64_elem(%struct.config_setting_t* %0, i32 %1) {
%3 = tail call %struct.config_setting_t* @config_setting_get_elem(%struct.config_setting_t* %0, i32 %1)
%4 = icmp eq %struct.config_setting_t* %3, null
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = tail call i64 @config_setting_get_int64(%struct.config_setting_t* %3)
br label %7
7: ; preds = %2, %5
%8 = phi i64 [ %6, %5 ], [ 0, %2 ]
ret i64 %8
}