#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 sscanf(char *, char *, int *);
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
int configIntVar(char *buf, char *matchStr, int *valp) {
  int varCount, temp = 0, len = strlen(matchStr);
  if (strncmp(buf, matchStr, len) == 0) {
    varCount = sscanf(&buf[len + 1], "%d", &temp);
    if (varCount == 1)
      *valp = temp;
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<configIntVar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x2c(%rbp),%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11b2 <configIntVar+0x82>
mov    -0x10(%rbp),%rdi
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
cltq
add    %rax,%rdi
lea    0xe79(%rip),%rsi
lea    -0x28(%rbp),%rdx
call   1050 <sscanf@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x1,-0x24(%rbp)
jne    11a6 <configIntVar+0x76>
mov    -0x28(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    11b9 <configIntVar+0x89>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<configIntVar>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
movl   $0x0,0x4(%rsp)
mov    %rsi,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jne    1198 <configIntVar+0x68>
movslq %ebp,%rax
lea    (%rax,%r15,1),%rdi
add    $0x1,%rdi
lea    0xe85(%rip),%rsi
lea    0x4(%rsp),%rdx
call   1050 <sscanf@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    $0x1,%ecx
jne    1198 <configIntVar+0x68>
mov    0x4(%rsp),%ecx
mov    %ecx,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @configIntVar(i8* %0, i8* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32* %2, i32** %7
store i32 0, i32* %9
%11 = load i8*, i8** %6
%12 = call i32 @strlen(i8* %11)
store i32 %12, i32* %10
%13 = load i8*, i8** %5
%14 = load i8*, i8** %6
%15 = load i32, i32* %10
%16 = call i64 @strncmp(i8* %13, i8* %14, i32 %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %31
18: ; preds = %3
%19 = load i8*, i8** %5
%20 = load i32, i32* %10
%21 = add nsw i32 %20, 1
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %19, i64 %22
%24 = call i32 @sscanf(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %9)
store i32 %24, i32* %8
%25 = load i32, i32* %8
%26 = icmp eq i32 %25, 1
br i1 %26, label %27, label %30
27: ; preds = %18
%28 = load i32, i32* %9
%29 = load i32*, i32** %7
store i32 %28, i32* %29
br label %30
30: ; preds = %27, %18
store i32 1, i32* %4
br label %32
31: ; preds = %3
store i32 0, i32* %4
br label %32
32: ; preds = %31, %30
%33 = load i32, i32* %4
ret i32 %33
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @configIntVar(i8* %0, i8* %1, i32* nocapture writeonly %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%6 = tail call i32 @strlen(i8* %1)
%7 = tail call i64 @strncmp(i8* %0, i8* %1, i32 %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %17
9: ; preds = %3
%10 = add nsw i32 %6, 1
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = call i32 @sscanf(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %17
15: ; preds = %9
%16 = load i32, i32* %4
store i32 %16, i32* %2
br label %17
17: ; preds = %3, %9, %15
%18 = phi i32 [ 1, %15 ], [ 1, %9 ], [ 0, %3 ]
ret i32 %18
}