#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int atoi(char *);
int get_value(int /*<<< orphan*/ *, char *, char *, char *);
int get_total_len(FILE *fd) {
  char len_str[5000] = {0};
  if (get_value(fd, "[len=", "]--", len_str) == 1) {
    int len = atoi(len_str);
    return len;
  }
  return 0;
}


x86 assembly (clang, -O0):
<get_total_len>:
push   %rbp
mov    %rsp,%rbp
sub    $0x13b0,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x13a0(%rbp),%rdi
xor    %esi,%esi
mov    $0x1388,%edx
call   1030 <memset@plt>
mov    -0x10(%rbp),%rdi
lea    -0x13a0(%rbp),%rcx
lea    0xe9c(%rip),%rsi
lea    0xe9b(%rip),%rdx
call   1040 <get_value@plt>
cmp    $0x1,%eax
jne    1199 <get_total_len+0x69>
lea    -0x13a0(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x13a4(%rbp)
mov    -0x13a4(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11a0 <get_total_len+0x70>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x13b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_total_len>:
push   %rbp
push   %r14
push   %rbx
sub    $0x1390,%rsp
mov    %rdi,%rbx
mov    %rsp,%r14
xor    %ebp,%ebp
mov    $0x1388,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <memset@plt>
lea    0xea7(%rip),%rsi
lea    0xea6(%rip),%rdx
mov    %rbx,%rdi
mov    %r14,%rcx
call   1040 <get_value@plt>
cmp    $0x1,%eax
jne    117a <get_total_len+0x4a>
mov    %rsp,%rdi
call   1050 <atoi@plt>
mov    %eax,%ebp
mov    %ebp,%eax
add    $0x1390,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"[len=\00"
@.str.1 = [4 x i8] c"]--\00"
define i32 @get_total_len(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca [5000 x i8]
%5 = alloca i32
store i32* %0, i32** %3
%6 = bitcast [5000 x i8]* %4 to i8*
%7 = load i32*, i32** %3
%8 = getelementptr inbounds [5000 x i8], [5000 x i8]* %4, i64 0, i64 0
%9 = call i32 @get_value(i32* %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %15
11: ; preds = %1
%12 = getelementptr inbounds [5000 x i8], [5000 x i8]* %4, i64 0, i64 0
%13 = call i32 @atoi(i8* %12)
store i32 %13, i32* %5
%14 = load i32, i32* %5
store i32 %14, i32* %2
br label %16
15: ; preds = %1
store i32 0, i32* %2
br label %16
16: ; preds = %15, %11
%17 = load i32, i32* %2
ret i32 %17
}

LLVM IR (-O2):
@.str = [6 x i8] c"[len=\00"
@.str.1 = [4 x i8] c"]--\00"
define i32 @get_total_len(i32* %0) {
%2 = alloca [5000 x i8]
%3 = getelementptr inbounds [5000 x i8], [5000 x i8]* %2, i64 0, i64 0
%4 = call i32 @get_value(i32* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%5 = icmp eq i32 %4, 1
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = call i32 @atoi(i8* %3)
br label %8
8: ; preds = %1, %6
%9 = phi i32 [ %7, %6 ], [ 0, %1 ]
ret i32 %9
}