#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 */

/* Variables and functions */
int get_value(char const *);
int strlen(char const *);
scalar_t__ strncmp(char const *, char const *, int);
int update_value(const char *line, int *val, const char *name) {
  int ret;
  if (strncmp(line, name, strlen(name)) == 0) {
    ret = get_value(line + strlen(name));
    if (ret < 0)
      return 0;
    *val = ret;
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<update_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11c3 <update_value+0x93>
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x40(%rbp),%rdi
cltq
add    %rax,%rdi
call   1050 <get_value@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    11ae <update_value+0x7e>
movl   $0x0,-0x4(%rbp)
jmp    11ca <update_value+0x9a>
mov    -0x24(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    11ca <update_value+0x9a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<update_value>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rdx,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
xor    %r15d,%r15d
test   %rax,%rax
jne    117f <update_value+0x4f>
mov    %rbp,%rdi
call   1040 <strlen@plt>
cltq
add    %rax,%rbx
mov    %rbx,%rdi
call   1050 <get_value@plt>
test   %eax,%eax
js     117f <update_value+0x4f>
mov    %eax,(%r14)
mov    $0x1,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @update_value(i8* %0, i32* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i32
store i8* %0, i8** %5
store i32* %1, i32** %6
store i8* %2, i8** %7
%9 = load i8*, i8** %5
%10 = load i8*, i8** %7
%11 = load i8*, i8** %7
%12 = call i32 @strlen(i8* %11)
%13 = call i64 @strncmp(i8* %9, i8* %10, i32 %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %28
15: ; preds = %3
%16 = load i8*, i8** %5
%17 = load i8*, i8** %7
%18 = call i32 @strlen(i8* %17)
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %16, i64 %19
%21 = call i32 @get_value(i8* %20)
store i32 %21, i32* %8
%22 = load i32, i32* %8
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %15
store i32 0, i32* %4
br label %29
25: ; preds = %15
%26 = load i32, i32* %8
%27 = load i32*, i32** %6
store i32 %26, i32* %27
store i32 1, i32* %4
br label %29
28: ; preds = %3
store i32 0, i32* %4
br label %29
29: ; preds = %28, %25, %24
%30 = load i32, i32* %4
ret i32 %30
}

LLVM IR (-O2):
define i32 @update_value(i8* %0, i32* nocapture writeonly %1, i8* %2) {
%4 = tail call i32 @strlen(i8* %2)
%5 = tail call i64 @strncmp(i8* %0, i8* %2, i32 %4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %14
7: ; preds = %3
%8 = tail call i32 @strlen(i8* %2)
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %0, i64 %9
%11 = tail call i32 @get_value(i8* %10)
%12 = icmp slt i32 %11, 0
br i1 %12, label %14, label %13
13: ; preds = %7
store i32 %11, i32* %1
br label %14
14: ; preds = %3, %7, %13
%15 = phi i32 [ 1, %13 ], [ 0, %7 ], [ 0, %3 ]
ret i32 %15
}