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

/* Variables and functions */
int /*<<< orphan*/ LOG_ALERT;
int /*<<< orphan*/ LOG_AUTHPRIV;
int /*<<< orphan*/ LOG_INFO;
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
int getline(char **, size_t *, int /*<<< orphan*/ *);
int /*<<< orphan*/ openlog(char *, int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ strcmp(char *, char *);
char *strdup(char *);
int strlen(char *);
char *strtok_r(char *, char *, char **);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, ...);
int sp_config(char **id, char **secret, char **app) {
  openlog("pam_stormpath", 0, LOG_AUTHPRIV);
  FILE *fp;
  char *line = NULL;
  char *token;
  char *saveptr;
  int rc = 0;
  size_t len = 0;
  ssize_t read;
  if (!(fp = fopen("/etc/pam_stormpath.conf", "r"))) {
    syslog(LOG_ALERT, "failed to read configuration file");
    return 1;
  }
  while ((read = getline(&line, &len, fp)) != -1) {
    token = strtok_r(line, "=", &saveptr);
    if (token) {
      if (strcmp(token, "SPID") == 0) {
        token = strtok_r(NULL, "=", &saveptr);
        if (token) {
          if (token[strlen(token) - 1] == '\n') {
            token[strlen(token) - 1] = '\0';
          }
          *id = strdup(token);
        }
      } else if (strcmp(token, "SPSECRET") == 0) {
        token = strtok_r(NULL, "=", &saveptr);
        if (token) {
          if (token[strlen(token) - 1] == '\n') {
            token[strlen(token) - 1] = '\0';
          }
          *secret = strdup(token);
        }
      } else if (strcmp(token, "SPAPPLICATION") == 0) {
        token = strtok_r(NULL, "=", &saveptr);
        if (token) {
          if (token[strlen(token) - 1] == '\n') {
            token[strlen(token) - 1] = '\0';
          }
          *app = strdup(token);
        }
      }
    }
  }
  free(line);
  if ((*id == NULL) || (*secret == NULL) || (*app == NULL)) {
    rc = 1;
  } else {
    syslog(LOG_INFO, "id: %s", *id);
    syslog(LOG_INFO, "secret: %s", *secret);
    syslog(LOG_INFO, "app: %s", *app);
    rc = 0;
  }
  return rc;
}


x86 assembly (clang, -O0):
<sp_config>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    0x2e2a(%rip),%rax
mov    (%rax),%edx
lea    0xe49(%rip),%rdi
xor    %esi,%esi
call   10a0 <openlog@plt>
movq   $0x0,-0x30(%rbp)
movl   $0x0,-0x44(%rbp)
movq   $0x0,-0x50(%rbp)
lea    0xe32(%rip),%rdi
lea    0xe43(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    1219 <sp_config+0x89>
mov    0x2deb(%rip),%rax
mov    (%rax),%edi
lea    0xe22(%rip),%rsi
mov    $0x0,%al
call   1070 <syslog@plt>
movl   $0x1,-0x4(%rbp)
jmp    14fe <sp_config+0x36e>
jmp    121e <sp_config+0x8e>
mov    -0x28(%rbp),%rdx
lea    -0x30(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1090 <getline@plt>
mov    %eax,-0x54(%rbp)
cmp    $0xffffffff,%eax
je     1458 <sp_config+0x2c8>
mov    -0x30(%rbp),%rdi
lea    0xe04(%rip),%rsi
lea    -0x40(%rbp),%rdx
call   1050 <strtok_r@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     1453 <sp_config+0x2c3>
mov    -0x38(%rbp),%rdi
lea    0xde3(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    12fe <sp_config+0x16e>
xor    %eax,%eax
mov    %eax,%edi
lea    0xdc7(%rip),%rsi
lea    -0x40(%rbp),%rdx
call   1050 <strtok_r@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     12f9 <sp_config+0x169>
mov    -0x38(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x38(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x60(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    12e6 <sp_config+0x156>
mov    -0x38(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x38(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x68(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x38(%rbp),%rdi
call   10b0 <strdup@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
jmp    144e <sp_config+0x2be>
mov    -0x38(%rbp),%rdi
lea    0xd48(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    139e <sp_config+0x20e>
xor    %eax,%eax
mov    %eax,%edi
lea    0xd27(%rip),%rsi
lea    -0x40(%rbp),%rdx
call   1050 <strtok_r@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     1399 <sp_config+0x209>
mov    -0x38(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x38(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x70(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    1386 <sp_config+0x1f6>
mov    -0x38(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x38(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x78(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x38(%rbp),%rdi
call   10b0 <strdup@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
jmp    1449 <sp_config+0x2b9>
mov    -0x38(%rbp),%rdi
lea    0xcb1(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1444 <sp_config+0x2b4>
xor    %eax,%eax
mov    %eax,%edi
lea    0xc87(%rip),%rsi
lea    -0x40(%rbp),%rdx
call   1050 <strtok_r@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     143f <sp_config+0x2af>
mov    -0x38(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x38(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x80(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    142c <sp_config+0x29c>
mov    -0x38(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x38(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x88(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x38(%rbp),%rdi
call   10b0 <strdup@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
jmp    1444 <sp_config+0x2b4>
jmp    1449 <sp_config+0x2b9>
jmp    144e <sp_config+0x2be>
jmp    1453 <sp_config+0x2c3>
jmp    121e <sp_config+0x8e>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     148b <sp_config+0x2fb>
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
je     148b <sp_config+0x2fb>
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1497 <sp_config+0x307>
movl   $0x1,-0x44(%rbp)
jmp    14f8 <sp_config+0x368>
mov    0x2b32(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xbba(%rip),%rsi
mov    $0x0,%al
call   1070 <syslog@plt>
mov    0x2b14(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rax
mov    (%rax),%rdx
lea    0xba3(%rip),%rsi
mov    $0x0,%al
call   1070 <syslog@plt>
mov    0x2af6(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rax
mov    (%rax),%rdx
lea    0xb90(%rip),%rsi
mov    $0x0,%al
call   1070 <syslog@plt>
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sp_config>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdx,%rbp
mov    %rsi,0x10(%rsp)
mov    %rdi,0x20(%rsp)
mov    0x2e26(%rip),%rax
mov    (%rax),%edx
lea    0xe45(%rip),%rdi
xor    %esi,%esi
call   10a0 <openlog@plt>
movq   $0x0,0x8(%rsp)
movq   $0x0,0x28(%rsp)
lea    0xe33(%rip),%rdi
lea    0xe44(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     13df <sp_config+0x24f>
mov    %rax,%rbx
mov    %rbp,0x18(%rsp)
lea    0x8(%rsp),%rdi
lea    0x28(%rsp),%rsi
mov    %rax,%rdx
call   1090 <getline@plt>
cmp    $0xffffffff,%eax
je     1362 <sp_config+0x1d2>
lea    0xe30(%rip),%r13
lea    0x30(%rsp),%r14
lea    0x28(%rsp),%r15
jmp    125b <sp_config+0xcb>
mov    %r12,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%r12,1)
mov    %r12,%rdi
call   10b0 <strdup@plt>
mov    %rax,0x0(%rbp)
lea    0x8(%rsp),%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1090 <getline@plt>
cmp    $0xffffffff,%eax
je     1362 <sp_config+0x1d2>
mov    0x8(%rsp),%rdi
mov    %r13,%rsi
mov    %r14,%rdx
call   1050 <strtok_r@plt>
test   %rax,%rax
je     1242 <sp_config+0xb2>
mov    %rax,%rbp
mov    %rax,%rdi
lea    0xdcf(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     12f0 <sp_config+0x160>
mov    %rbp,%rdi
lea    0xdc0(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1329 <sp_config+0x199>
mov    %rbp,%rdi
lea    0xdb1(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    1242 <sp_config+0xb2>
xor    %edi,%edi
mov    %r13,%rsi
mov    %r14,%rdx
call   1050 <strtok_r@plt>
test   %rax,%rax
je     1242 <sp_config+0xb2>
mov    %rax,%r12
mov    %rax,%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%r12,1)
mov    0x18(%rsp),%rbp
je     1226 <sp_config+0x96>
jmp    1236 <sp_config+0xa6>
nopl   0x0(%rax)
xor    %edi,%edi
mov    %r13,%rsi
mov    %r14,%rdx
call   1050 <strtok_r@plt>
test   %rax,%rax
je     1242 <sp_config+0xb2>
mov    %rax,%r12
mov    %rax,%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%r12,1)
mov    0x20(%rsp),%rbp
je     1226 <sp_config+0x96>
jmp    1236 <sp_config+0xa6>
xor    %edi,%edi
mov    %r13,%rsi
mov    %r14,%rdx
call   1050 <strtok_r@plt>
test   %rax,%rax
je     1242 <sp_config+0xb2>
mov    %rax,%r12
mov    %rax,%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%r12,1)
mov    0x10(%rsp),%rbp
je     1226 <sp_config+0x96>
jmp    1236 <sp_config+0xa6>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    0x20(%rsp),%rax
mov    (%rax),%rdx
mov    $0x1,%ebx
test   %rdx,%rdx
je     13fb <sp_config+0x26b>
mov    0x10(%rsp),%rax
cmpq   $0x0,(%rax)
je     13fb <sp_config+0x26b>
mov    0x18(%rsp),%rbp
cmpq   $0x0,0x0(%rbp)
je     13fb <sp_config+0x26b>
mov    0x2c34(%rip),%r14
mov    (%r14),%edi
lea    0xcc2(%rip),%rsi
xor    %ebx,%ebx
xor    %eax,%eax
call   1070 <syslog@plt>
mov    (%r14),%edi
mov    0x10(%rsp),%rax
mov    (%rax),%rdx
lea    0xcae(%rip),%rsi
xor    %eax,%eax
call   1070 <syslog@plt>
mov    (%r14),%edi
mov    0x0(%rbp),%rdx
lea    0xca4(%rip),%rsi
xor    %eax,%eax
call   1070 <syslog@plt>
jmp    13fb <sp_config+0x26b>
mov    0x2c02(%rip),%rax
mov    (%rax),%edi
lea    0xc39(%rip),%rsi
xor    %eax,%eax
call   1070 <syslog@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"pam_stormpath\00"
@LOG_AUTHPRIV = global i32 0
@.str.1 = [24 x i8] c"/etc/pam_stormpath.conf\00"
@.str.2 = [2 x i8] c"r\00"
@LOG_ALERT = global i32 0
@.str.3 = [34 x i8] c"failed to read configuration file\00"
@.str.4 = [2 x i8] c"=\00"
@.str.5 = [5 x i8] c"SPID\00"
@.str.6 = [9 x i8] c"SPSECRET\00"
@.str.7 = [14 x i8] c"SPAPPLICATION\00"
@LOG_INFO = global i32 0
@.str.8 = [7 x i8] c"id: %s\00"
@.str.9 = [11 x i8] c"secret: %s\00"
@.str.10 = [8 x i8] c"app: %s\00"
define i32 @sp_config(i8** %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i32*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i64
%14 = alloca i32
store i8** %0, i8*** %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%15 = load i32, i32* @LOG_AUTHPRIV
%16 = call i32 @openlog(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 0, i32 %15)
store i8* null, i8** %9
store i32 0, i32* %12
store i64 0, i64* %13
%17 = call i32* @fopen(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %17, i32** %8
%18 = icmp ne i32* %17, null
br i1 %18, label %22, label %19
19: ; preds = %3
%20 = load i32, i32* @LOG_ALERT
%21 = call i32 (i32, i8*, ...) @syslog(i32 %20, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %4
br label %156
22: ; preds = %3
br label %23
23: ; preds = %125, %22
%24 = load i32*, i32** %8
%25 = call i32 @getline(i8** %9, i64* %13, i32* %24)
store i32 %25, i32* %14
%26 = icmp ne i32 %25, -1
br i1 %26, label %27, label %126
27: ; preds = %23
%28 = load i8*, i8** %9
%29 = call i8* @strtok_r(i8* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8** %11)
store i8* %29, i8** %10
%30 = load i8*, i8** %10
%31 = icmp ne i8* %30, null
br i1 %31, label %32, label %125
32: ; preds = %27
%33 = load i8*, i8** %10
%34 = call i64 @strcmp(i8* %33, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %62
36: ; preds = %32
%37 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8** %11)
store i8* %37, i8** %10
%38 = load i8*, i8** %10
%39 = icmp ne i8* %38, null
br i1 %39, label %40, label %61
40: ; preds = %36
%41 = load i8*, i8** %10
%42 = load i8*, i8** %10
%43 = call i32 @strlen(i8* %42)
%44 = sub nsw i32 %43, 1
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %41, i64 %45
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = icmp eq i32 %48, 10
br i1 %49, label %50, label %57
50: ; preds = %40
%51 = load i8*, i8** %10
%52 = load i8*, i8** %10
%53 = call i32 @strlen(i8* %52)
%54 = sub nsw i32 %53, 1
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %51, i64 %55
store i8 0, i8* %56
br label %57
57: ; preds = %50, %40
%58 = load i8*, i8** %10
%59 = call i8* @strdup(i8* %58)
%60 = load i8**, i8*** %5
store i8* %59, i8** %60
br label %61
61: ; preds = %57, %36
br label %124
62: ; preds = %32
%63 = load i8*, i8** %10
%64 = call i64 @strcmp(i8* %63, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%65 = icmp eq i64 %64, 0
br i1 %65, label %66, label %92
66: ; preds = %62
%67 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8** %11)
store i8* %67, i8** %10
%68 = load i8*, i8** %10
%69 = icmp ne i8* %68, null
br i1 %69, label %70, label %91
70: ; preds = %66
%71 = load i8*, i8** %10
%72 = load i8*, i8** %10
%73 = call i32 @strlen(i8* %72)
%74 = sub nsw i32 %73, 1
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds i8, i8* %71, i64 %75
%77 = load i8, i8* %76
%78 = sext i8 %77 to i32
%79 = icmp eq i32 %78, 10
br i1 %79, label %80, label %87
80: ; preds = %70
%81 = load i8*, i8** %10
%82 = load i8*, i8** %10
%83 = call i32 @strlen(i8* %82)
%84 = sub nsw i32 %83, 1
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds i8, i8* %81, i64 %85
store i8 0, i8* %86
br label %87
87: ; preds = %80, %70
%88 = load i8*, i8** %10
%89 = call i8* @strdup(i8* %88)
%90 = load i8**, i8*** %6
store i8* %89, i8** %90
br label %91
91: ; preds = %87, %66
br label %123
92: ; preds = %62
%93 = load i8*, i8** %10
%94 = call i64 @strcmp(i8* %93, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
%95 = icmp eq i64 %94, 0
br i1 %95, label %96, label %122
96: ; preds = %92
%97 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8** %11)
store i8* %97, i8** %10
%98 = load i8*, i8** %10
%99 = icmp ne i8* %98, null
br i1 %99, label %100, label %121
100: ; preds = %96
%101 = load i8*, i8** %10
%102 = load i8*, i8** %10
%103 = call i32 @strlen(i8* %102)
%104 = sub nsw i32 %103, 1
%105 = sext i32 %104 to i64
%106 = getelementptr inbounds i8, i8* %101, i64 %105
%107 = load i8, i8* %106
%108 = sext i8 %107 to i32
%109 = icmp eq i32 %108, 10
br i1 %109, label %110, label %117
110: ; preds = %100
%111 = load i8*, i8** %10
%112 = load i8*, i8** %10
%113 = call i32 @strlen(i8* %112)
%114 = sub nsw i32 %113, 1
%115 = sext i32 %114 to i64
%116 = getelementptr inbounds i8, i8* %111, i64 %115
store i8 0, i8* %116
br label %117
117: ; preds = %110, %100
%118 = load i8*, i8** %10
%119 = call i8* @strdup(i8* %118)
%120 = load i8**, i8*** %7
store i8* %119, i8** %120
br label %121
121: ; preds = %117, %96
br label %122
122: ; preds = %121, %92
br label %123
123: ; preds = %122, %91
br label %124
124: ; preds = %123, %61
br label %125
125: ; preds = %124, %27
br label %23
126: ; preds = %23
%127 = load i8*, i8** %9
%128 = call i32 @free(i8* %127)
%129 = load i8**, i8*** %5
%130 = load i8*, i8** %129
%131 = icmp eq i8* %130, null
br i1 %131, label %140, label %132
132: ; preds = %126
%133 = load i8**, i8*** %6
%134 = load i8*, i8** %133
%135 = icmp eq i8* %134, null
br i1 %135, label %140, label %136
136: ; preds = %132
%137 = load i8**, i8*** %7
%138 = load i8*, i8** %137
%139 = icmp eq i8* %138, null
br i1 %139, label %140, label %141
140: ; preds = %136, %132, %126
store i32 1, i32* %12
br label %154
141: ; preds = %136
%142 = load i32, i32* @LOG_INFO
%143 = load i8**, i8*** %5
%144 = load i8*, i8** %143
%145 = call i32 (i32, i8*, ...) @syslog(i32 %142, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i8* %144)
%146 = load i32, i32* @LOG_INFO
%147 = load i8**, i8*** %6
%148 = load i8*, i8** %147
%149 = call i32 (i32, i8*, ...) @syslog(i32 %146, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i8* %148)
%150 = load i32, i32* @LOG_INFO
%151 = load i8**, i8*** %7
%152 = load i8*, i8** %151
%153 = call i32 (i32, i8*, ...) @syslog(i32 %150, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0), i8* %152)
store i32 0, i32* %12
br label %154
154: ; preds = %141, %140
%155 = load i32, i32* %12
store i32 %155, i32* %4
br label %156
156: ; preds = %154, %19
%157 = load i32, i32* %4
ret i32 %157
}

LLVM IR (-O2):
@.str = [14 x i8] c"pam_stormpath\00"
@LOG_AUTHPRIV = global i32 0
@.str.1 = [24 x i8] c"/etc/pam_stormpath.conf\00"
@.str.2 = [2 x i8] c"r\00"
@LOG_ALERT = global i32 0
@.str.3 = [34 x i8] c"failed to read configuration file\00"
@.str.4 = [2 x i8] c"=\00"
@.str.5 = [5 x i8] c"SPID\00"
@.str.6 = [9 x i8] c"SPSECRET\00"
@.str.7 = [14 x i8] c"SPAPPLICATION\00"
@LOG_INFO = global i32 0
@.str.8 = [7 x i8] c"id: %s\00"
@.str.9 = [11 x i8] c"secret: %s\00"
@.str.10 = [8 x i8] c"app: %s\00"
define i32 @sp_config(i8** nocapture %0, i8** nocapture %1, i8** nocapture %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = load i32, i32* @LOG_AUTHPRIV
%8 = tail call i32 @openlog(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 0, i32 %7)
%9 = bitcast i8** %4 to i8*
store i8* null, i8** %4
%10 = bitcast i8** %5 to i8*
%11 = bitcast i64* %6 to i8*
store i64 0, i64* %6
%12 = tail call i32* @fopen(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %17, label %14
14: ; preds = %3
%15 = call i32 @getline(i8** %4, i64* %6, i32* %12)
%16 = icmp eq i32 %15, -1
br i1 %16, label %77, label %20
17: ; preds = %3
%18 = load i32, i32* @LOG_ALERT
%19 = tail call i32 (i32, i8*, ...) @syslog(i32 %18, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
br label %97
20: ; preds = %14, %74
%21 = load i8*, i8** %4
%22 = call i8* @strtok_r(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8** %5)
%23 = icmp eq i8* %22, null
br i1 %23, label %74, label %24
24: ; preds = %20
%25 = call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %37
27: ; preds = %24
%28 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8** %5)
%29 = icmp eq i8* %28, null
br i1 %29, label %74, label %30
30: ; preds = %27
%31 = call i32 @strlen(i8* %28)
%32 = add nsw i32 %31, -1
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %28, i64 %33
%35 = load i8, i8* %34
%36 = icmp eq i8 %35, 10
br i1 %36, label %63, label %70
37: ; preds = %24
%38 = call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %50
40: ; preds = %37
%41 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8** %5)
%42 = icmp eq i8* %41, null
br i1 %42, label %74, label %43
43: ; preds = %40
%44 = call i32 @strlen(i8* %41)
%45 = add nsw i32 %44, -1
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* %41, i64 %46
%48 = load i8, i8* %47
%49 = icmp eq i8 %48, 10
br i1 %49, label %63, label %70
50: ; preds = %37
%51 = call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
%52 = icmp eq i64 %51, 0
br i1 %52, label %53, label %74
53: ; preds = %50
%54 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8** %5)
%55 = icmp eq i8* %54, null
br i1 %55, label %74, label %56
56: ; preds = %53
%57 = call i32 @strlen(i8* %54)
%58 = add nsw i32 %57, -1
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i8, i8* %54, i64 %59
%61 = load i8, i8* %60
%62 = icmp eq i8 %61, 10
br i1 %62, label %63, label %70
63: ; preds = %56, %43, %30
%64 = phi i8* [ %28, %30 ], [ %41, %43 ], [ %54, %56 ]
%65 = phi i8** [ %0, %30 ], [ %1, %43 ], [ %2, %56 ]
%66 = call i32 @strlen(i8* %64)
%67 = add nsw i32 %66, -1
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i8, i8* %64, i64 %68
store i8 0, i8* %69
br label %70
70: ; preds = %63, %56, %43, %30
%71 = phi i8* [ %28, %30 ], [ %41, %43 ], [ %54, %56 ], [ %64, %63 ]
%72 = phi i8** [ %0, %30 ], [ %1, %43 ], [ %2, %56 ], [ %65, %63 ]
%73 = call i8* @strdup(i8* %71)
store i8* %73, i8** %72
br label %74
74: ; preds = %70, %27, %50, %53, %40, %20
%75 = call i32 @getline(i8** %4, i64* %6, i32* %12)
%76 = icmp eq i32 %75, -1
br i1 %76, label %77, label %20
77: ; preds = %74, %14
%78 = load i8*, i8** %4
%79 = call i32 @free(i8* %78)
%80 = load i8*, i8** %0
%81 = icmp eq i8* %80, null
br i1 %81, label %97, label %82
82: ; preds = %77
%83 = load i8*, i8** %1
%84 = icmp eq i8* %83, null
br i1 %84, label %97, label %85
85: ; preds = %82
%86 = load i8*, i8** %2
%87 = icmp eq i8* %86, null
br i1 %87, label %97, label %88
88: ; preds = %85
%89 = load i32, i32* @LOG_INFO
%90 = call i32 (i32, i8*, ...) @syslog(i32 %89, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i8* %80)
%91 = load i32, i32* @LOG_INFO
%92 = load i8*, i8** %1
%93 = call i32 (i32, i8*, ...) @syslog(i32 %91, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i8* %92)
%94 = load i32, i32* @LOG_INFO
%95 = load i8*, i8** %2
%96 = call i32 (i32, i8*, ...) @syslog(i32 %94, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0), i8* %95)
br label %97
97: ; preds = %88, %85, %82, %77, %17
%98 = phi i32 [ 1, %17 ], [ 0, %88 ], [ 1, %85 ], [ 1, %82 ], [ 1, %77 ]
ret i32 %98
}