#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 const *, char *);
char *getenv(char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int /*<<< orphan*/ sscanf(char *, char *, ...);
int strlen(char *);
int /*<<< orphan*/ strncmp(char *, char *, int);
void getconfig(const char *fn, double *defaultvol, double *increment,
               char *wait_time) {
  FILE *conf;
  char buf[256];
  if (!fn) {
    snprintf(buf, sizeof buf, "%s/.fmrc", getenv("HOME"));
    fn = buf;
  }
  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 %lf", defaultvol);
    if (!strncmp(buf, "INCR", 3))
      sscanf(buf, "%*s %lf", 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    $0x140,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    11e6 <getconfig+0x66>
lea    -0x130(%rbp),%rax
mov    %rax,-0x138(%rbp)
lea    0xe4e(%rip),%rdi
call   1030 <getenv@plt>
mov    -0x138(%rbp),%rdi
mov    %rax,%rcx
mov    $0x100,%esi
lea    0xe2a(%rip),%rdx
call   1070 <snprintf@plt>
lea    -0x130(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe1d(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    120a <getconfig+0x8a>
jmp    1303 <getconfig+0x183>
jmp    120f <getconfig+0x8f>
lea    -0x130(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    $0x100,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     12fa <getconfig+0x17a>
lea    -0x130(%rbp),%rdi
call   1060 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x130(%rbp,%rax,1)
lea    -0x130(%rbp),%rdi
lea    0xdbb(%rip),%rsi
mov    $0x3,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
jne    1281 <getconfig+0x101>
lea    -0x130(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xd9a(%rip),%rsi
mov    $0x0,%al
call   1090 <sscanf@plt>
lea    -0x130(%rbp),%rdi
lea    0xd8d(%rip),%rsi
mov    $0x3,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
jne    12bb <getconfig+0x13b>
lea    -0x130(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xd60(%rip),%rsi
mov    $0x0,%al
call   1090 <sscanf@plt>
lea    -0x130(%rbp),%rdi
lea    0xd58(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
jne    12f5 <getconfig+0x175>
lea    -0x130(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xd38(%rip),%rsi
mov    $0x0,%al
call   1090 <sscanf@plt>
jmp    120f <getconfig+0x8f>
mov    -0x28(%rbp),%rdi
call   1050 <fclose@plt>
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getconfig>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x128,%rsp
mov    %rcx,0x18(%rsp)
mov    %rdx,0x10(%rsp)
mov    %rsi,0x8(%rsp)
mov    %rdi,%rbx
test   %rdi,%rdi
jne    11d0 <getconfig+0x50>
lea    0x20(%rsp),%rbx
lea    0xe55(%rip),%rdi
call   1030 <getenv@plt>
lea    0xe40(%rip),%rdx
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %rax,%rcx
call   1070 <snprintf@plt>
lea    0xe37(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <fopen@plt>
test   %rax,%rax
je     12df <getconfig+0x15f>
mov    %rax,%r13
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %rax,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     12d7 <getconfig+0x157>
lea    0xe00(%rip),%rbp
lea    0xdfd(%rip),%r14
lea    0xdfe(%rip),%r15
lea    0xdfc(%rip),%r12
jmp    1249 <getconfig+0xc9>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %r13,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     12d7 <getconfig+0x157>
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    127e <getconfig+0xfe>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    0x8(%rsp),%rdx
xor    %eax,%eax
call   1090 <sscanf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x3,%edx
call   1040 <strncmp@plt>
test   %eax,%eax
jne    12a4 <getconfig+0x124>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    0x10(%rsp),%rdx
xor    %eax,%eax
call   1090 <sscanf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
test   %eax,%eax
jne    1230 <getconfig+0xb0>
mov    %rbx,%rdi
lea    0xd60(%rip),%rsi
mov    0x18(%rsp),%rdx
xor    %eax,%eax
call   1090 <sscanf@plt>
jmp    1230 <getconfig+0xb0>
mov    %r13,%rdi
call   1050 <fclose@plt>
add    $0x128,%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 = [8 x i8] c"%*s %lf\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(i8* %0, double* %1, double* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca double*
%7 = alloca double*
%8 = alloca i8*
%9 = alloca i32*
%10 = alloca [256 x i8]
store i8* %0, i8** %5
store double* %1, double** %6
store double* %2, double** %7
store i8* %3, i8** %8
%11 = load i8*, i8** %5
%12 = icmp ne i8* %11, null
br i1 %12, label %18, label %13
13: ; preds = %4
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%15 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 @snprintf(i8* %14, i32 256, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
store i8* %17, i8** %5
br label %18
18: ; preds = %13, %4
%19 = load i8*, i8** %5
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %20, i32** %9
%21 = load i32*, i32** %9
%22 = icmp ne i32* %21, null
br i1 %22, label %24, label %23
23: ; preds = %18
br label %63
24: ; preds = %18
br label %25
25: ; preds = %59, %24
%26 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%27 = load i32*, i32** %9
%28 = call i64 @fgets(i8* %26, i32 256, i32* %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %60
30: ; preds = %25
%31 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%32 = call i32 @strlen(i8* %31)
%33 = sub nsw i32 %32, 1
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 %34
store i8 0, i8* %35
%36 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%37 = call i32 @strncmp(i8* %36, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 3)
%38 = icmp ne i32 %37, 0
br i1 %38, label %43, label %39
39: ; preds = %30
%40 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%41 = load double*, double** %6
%42 = call i32 (i8*, i8*, ...) @sscanf(i8* %40, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), double* %41)
br label %43
43: ; preds = %39, %30
%44 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%45 = call i32 @strncmp(i8* %44, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 3)
%46 = icmp ne i32 %45, 0
br i1 %46, label %51, label %47
47: ; preds = %43
%48 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%49 = load double*, double** %7
%50 = call i32 (i8*, i8*, ...) @sscanf(i8* %48, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), double* %49)
br label %51
51: ; preds = %47, %43
%52 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%53 = call i32 @strncmp(i8* %52, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 4)
%54 = icmp ne i32 %53, 0
br i1 %54, label %59, label %55
55: ; preds = %51
%56 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%57 = load i8*, i8** %8
%58 = call i32 (i8*, i8*, ...) @sscanf(i8* %56, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* %57)
br label %59
59: ; preds = %55, %51
br label %25
60: ; preds = %25
%61 = load i32*, i32** %9
%62 = call i32 @fclose(i32* %61)
br label %63
63: ; preds = %60, %23
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 = [8 x i8] c"%*s %lf\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(i8* %0, double* %1, double* %2, i8* %3) {
%5 = alloca [256 x i8]
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%7 = icmp eq i8* %0, null
br i1 %7, label %8, label %11
8: ; preds = %4
%9 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @snprintf(i8* %6, i32 256, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %9)
br label %11
11: ; preds = %8, %4
%12 = phi i8* [ %0, %4 ], [ %6, %8 ]
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp eq i32* %13, null
br i1 %14, label %42, label %15
15: ; preds = %11
%16 = call i64 @fgets(i8* %6, i32 256, i32* %13)
%17 = icmp eq i64 %16, 0
br i1 %17, label %40, label %18
18: ; preds = %15, %37
%19 = call i32 @strlen(i8* %6)
%20 = add nsw i32 %19, -1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 %21
store i8 0, i8* %22
%23 = call i32 @strncmp(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 3)
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %18
%26 = call i32 (i8*, i8*, ...) @sscanf(i8* %6, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), double* %1)
br label %27
27: ; preds = %25, %18
%28 = call i32 @strncmp(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 3)
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = call i32 (i8*, i8*, ...) @sscanf(i8* %6, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), double* %2)
br label %32
32: ; preds = %30, %27
%33 = call i32 @strncmp(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 4)
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %32
%36 = call i32 (i8*, i8*, ...) @sscanf(i8* %6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* %3)
br label %37
37: ; preds = %35, %32
%38 = call i64 @fgets(i8* %6, i32 256, i32* %13)
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %18
40: ; preds = %37, %15
%41 = call i32 @fclose(i32* %13)
br label %42
42: ; preds = %11, %40
ret void
}