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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
char *getenv(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ sscanf(char *, char *, ...);
int strlen(char *);
int /*<<< orphan*/ strncmp(char *, char *, int);
void getconfig(int *defaultvol, int *increment, char *wait_time) {
  FILE *conf;
  char buf[256], fn[256];
  sprintf(fn, "%s/.fmrc", getenv("HOME"));
  conf = fopen(fn, "r");
  if (!conf)
    return;
  while (fgets(buf, sizeof(buf), conf)) {
    buf[strlen(buf) - 1] = 0;
    if (!strncmp(buf, "VOL", 3))
      sscanf(buf, "%*s %i", defaultvol);
    if (!strncmp(buf, "INCR", 3))
      sscanf(buf, "%*s %i", increment);
    if (!strncmp(buf, "TIME", 4))
      sscanf(buf, "%*s %s", wait_time);
  }
  fclose(conf);
}


x86 assembly (clang, -O0):
<getconfig>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x220(%rbp),%rax
mov    %rax,-0x228(%rbp)
lea    0xe5d(%rip),%rdi
call   1030 <getenv@plt>
mov    -0x228(%rbp),%rdi
mov    %rax,%rdx
lea    0xe3e(%rip),%rsi
call   10a0 <sprintf@plt>
lea    -0x220(%rbp),%rdi
lea    0xe39(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11ee <getconfig+0x6e>
jmp    12e7 <getconfig+0x167>
jmp    11f3 <getconfig+0x73>
lea    -0x120(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x100,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     12de <getconfig+0x15e>
lea    -0x120(%rbp),%rdi
call   1060 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x120(%rbp,%rax,1)
lea    -0x120(%rbp),%rdi
lea    0xdd7(%rip),%rsi
mov    $0x3,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
jne    1265 <getconfig+0xe5>
lea    -0x120(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xdb6(%rip),%rsi
mov    $0x0,%al
call   1080 <sscanf@plt>
lea    -0x120(%rbp),%rdi
lea    0xda8(%rip),%rsi
mov    $0x3,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
jne    129f <getconfig+0x11f>
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xd7c(%rip),%rsi
mov    $0x0,%al
call   1080 <sscanf@plt>
lea    -0x120(%rbp),%rdi
lea    0xd73(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
jne    12d9 <getconfig+0x159>
lea    -0x120(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xd53(%rip),%rsi
mov    $0x0,%al
call   1080 <sscanf@plt>
jmp    11f3 <getconfig+0x73>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getconfig>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x228,%rsp
mov    %rdx,0x18(%rsp)
mov    %rsi,0x10(%rsp)
mov    %rdi,0x8(%rsp)
lea    0xe62(%rip),%rdi
call   1030 <getenv@plt>
lea    0xe4d(%rip),%rsi
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    %rax,%rdx
call   10a0 <sprintf@plt>
lea    0xe44(%rip),%rsi
mov    %rbx,%rdi
call   1090 <fopen@plt>
test   %rax,%rax
je     12cf <getconfig+0x14f>
mov    %rax,%r13
lea    0x120(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %rax,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     12c7 <getconfig+0x147>
lea    0xe0a(%rip),%rbp
lea    0xe07(%rip),%r14
lea    0xe07(%rip),%r15
lea    0xe05(%rip),%r12
jmp    1239 <getconfig+0xb9>
nopl   (%rax)
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %r13,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     12c7 <getconfig+0x147>
mov    %rbx,%rdi
call   1060 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    $0x3,%edx
call   1040 <strncmp@plt>
test   %eax,%eax
jne    126e <getconfig+0xee>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    0x8(%rsp),%rdx
xor    %eax,%eax
call   1080 <sscanf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x3,%edx
call   1040 <strncmp@plt>
test   %eax,%eax
jne    1294 <getconfig+0x114>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    0x10(%rsp),%rdx
xor    %eax,%eax
call   1080 <sscanf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
test   %eax,%eax
jne    1220 <getconfig+0xa0>
mov    %rbx,%rdi
lea    0xd6f(%rip),%rsi
mov    0x18(%rsp),%rdx
xor    %eax,%eax
call   1080 <sscanf@plt>
jmp    1220 <getconfig+0xa0>
mov    %r13,%rdi
call   1050 <fclose@plt>
add    $0x228,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"%s/.fmrc\00"
@.str.1 = [5 x i8] c"HOME\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [4 x i8] c"VOL\00"
@.str.4 = [7 x i8] c"%*s %i\00"
@.str.5 = [5 x i8] c"INCR\00"
@.str.6 = [5 x i8] c"TIME\00"
@.str.7 = [7 x i8] c"%*s %s\00"
define void @getconfig(i32* %0, i32* %1, i8* %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca [256 x i8]
%9 = alloca [256 x i8]
store i32* %0, i32** %4
store i32* %1, i32** %5
store i8* %2, i8** %6
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%11 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @sprintf(i8* %10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %14, i32** %7
%15 = load i32*, i32** %7
%16 = icmp ne i32* %15, null
br i1 %16, label %18, label %17
17: ; preds = %3
br label %57
18: ; preds = %3
br label %19
19: ; preds = %53, %18
%20 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%21 = load i32*, i32** %7
%22 = call i64 @fgets(i8* %20, i32 256, i32* %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %54
24: ; preds = %19
%25 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%26 = call i32 @strlen(i8* %25)
%27 = sub nsw i32 %26, 1
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 %28
store i8 0, i8* %29
%30 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%31 = call i32 @strncmp(i8* %30, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 3)
%32 = icmp ne i32 %31, 0
br i1 %32, label %37, label %33
33: ; preds = %24
%34 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%35 = load i32*, i32** %4
%36 = call i32 (i8*, i8*, ...) @sscanf(i8* %34, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32* %35)
br label %37
37: ; preds = %33, %24
%38 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%39 = call i32 @strncmp(i8* %38, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 3)
%40 = icmp ne i32 %39, 0
br i1 %40, label %45, label %41
41: ; preds = %37
%42 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%43 = load i32*, i32** %5
%44 = call i32 (i8*, i8*, ...) @sscanf(i8* %42, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32* %43)
br label %45
45: ; preds = %41, %37
%46 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%47 = call i32 @strncmp(i8* %46, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 4)
%48 = icmp ne i32 %47, 0
br i1 %48, label %53, label %49
49: ; preds = %45
%50 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%51 = load i8*, i8** %6
%52 = call i32 (i8*, i8*, ...) @sscanf(i8* %50, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* %51)
br label %53
53: ; preds = %49, %45
br label %19
54: ; preds = %19
%55 = load i32*, i32** %7
%56 = call i32 @fclose(i32* %55)
br label %57
57: ; preds = %54, %17
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"%s/.fmrc\00"
@.str.1 = [5 x i8] c"HOME\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [4 x i8] c"VOL\00"
@.str.4 = [7 x i8] c"%*s %i\00"
@.str.5 = [5 x i8] c"INCR\00"
@.str.6 = [5 x i8] c"TIME\00"
@.str.7 = [7 x i8] c"%*s %s\00"
define void @getconfig(i32* %0, i32* %1, i8* %2) {
%4 = alloca [256 x i8]
%5 = alloca [256 x i8]
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%8 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %39, label %12
12: ; preds = %3
%13 = call i64 @fgets(i8* %6, i32 256, i32* %10)
%14 = icmp eq i64 %13, 0
br i1 %14, label %37, label %15
15: ; preds = %12, %34
%16 = call i32 @strlen(i8* %6)
%17 = add nsw i32 %16, -1
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 %18
store i8 0, i8* %19
%20 = call i32 @strncmp(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 3)
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %15
%23 = call i32 (i8*, i8*, ...) @sscanf(i8* %6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32* %0)
br label %24
24: ; preds = %22, %15
%25 = call i32 @strncmp(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 3)
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %24
%28 = call i32 (i8*, i8*, ...) @sscanf(i8* %6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32* %1)
br label %29
29: ; preds = %27, %24
%30 = call i32 @strncmp(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 4)
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %29
%33 = call i32 (i8*, i8*, ...) @sscanf(i8* %6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* %2)
br label %34
34: ; preds = %32, %29
%35 = call i64 @fgets(i8* %6, i32 256, i32* %10)
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %15
37: ; preds = %34, %12
%38 = call i32 @fclose(i32* %10)
br label %39
39: ; preds = %3, %37
ret void
}