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

/* Variables and functions */
int get_elem_data(struct elem_vec *);
int parse_input(char const *, struct elem_vec *);
int shorten_elem_vec(struct elem_vec *);
int process_input(const char *in, struct elem_vec *evec) {
  int err = 0;
  err = parse_input(in, evec);
  if (err)
    return err;
  err = shorten_elem_vec(evec);
  if (err)
    return err;
  err = get_elem_data(evec);
  if (err)
    return err;
  return 0;
}


x86 assembly (clang, -O0):
<process_input>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <parse_input@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     116c <process_input+0x3c>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11b5 <process_input+0x85>
mov    -0x18(%rbp),%rdi
call   1050 <shorten_elem_vec@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     118d <process_input+0x5d>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11b5 <process_input+0x85>
mov    -0x18(%rbp),%rdi
call   1030 <get_elem_data@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     11ae <process_input+0x7e>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11b5 <process_input+0x85>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process_input>:
push   %rbx
mov    %rsi,%rbx
call   1040 <parse_input@plt>
test   %eax,%eax
jne    1149 <process_input+0x19>
mov    %rbx,%rdi
call   1050 <shorten_elem_vec@plt>
test   %eax,%eax
je     114b <process_input+0x1b>
pop    %rbx
ret
mov    %rbx,%rdi
pop    %rbx
jmp    1030 <get_elem_data@plt>

LLVM IR (-O0):
%struct.elem_vec = type { i32 }
define i32 @process_input(i8* %0, %struct.elem_vec* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca %struct.elem_vec*
%6 = alloca i32
store i8* %0, i8** %4
store %struct.elem_vec* %1, %struct.elem_vec** %5
store i32 0, i32* %6
%7 = load i8*, i8** %4
%8 = load %struct.elem_vec*, %struct.elem_vec** %5
%9 = call i32 @parse_input(i8* %7, %struct.elem_vec* %8)
store i32 %9, i32* %6
%10 = load i32, i32* %6
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = load i32, i32* %6
store i32 %13, i32* %3
br label %29
14: ; preds = %2
%15 = load %struct.elem_vec*, %struct.elem_vec** %5
%16 = call i32 @shorten_elem_vec(%struct.elem_vec* %15)
store i32 %16, i32* %6
%17 = load i32, i32* %6
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %14
%20 = load i32, i32* %6
store i32 %20, i32* %3
br label %29
21: ; preds = %14
%22 = load %struct.elem_vec*, %struct.elem_vec** %5
%23 = call i32 @get_elem_data(%struct.elem_vec* %22)
store i32 %23, i32* %6
%24 = load i32, i32* %6
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %21
%27 = load i32, i32* %6
store i32 %27, i32* %3
br label %29
28: ; preds = %21
store i32 0, i32* %3
br label %29
29: ; preds = %28, %26, %19, %12
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
%struct.elem_vec = type { i32 }
define i32 @process_input(i8* %0, %struct.elem_vec* %1) {
%3 = tail call i32 @parse_input(i8* %0, %struct.elem_vec* %1)
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %10
5: ; preds = %2
%6 = tail call i32 @shorten_elem_vec(%struct.elem_vec* %1)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = tail call i32 @get_elem_data(%struct.elem_vec* %1)
br label %10
10: ; preds = %8, %5, %2
%11 = phi i32 [ %3, %2 ], [ %6, %5 ], [ %9, %8 ]
ret i32 %11
}