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

/* Variables and functions */
int /*<<< orphan*/ assert(char *);
char *calloc(int, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ sscanf(char *, char *, char *);
char *strcat(char *, char *);
scalar_t__ strcmp(char *, char *);
char *strtok(char *, char *);
int /*<<< orphan*/ system(char *);
int checkProfiles(int profileExists, char *uname, char *hostname) {
  FILE *fp;
  char buf[2048];
  char *inputLine = calloc(80, sizeof(char));
  assert(inputLine);
  char *testUname = calloc(30, sizeof(char));
  assert(testUname);
  char *testHostname = calloc(50, sizeof(char));
  assert(testHostname);
  fp = fopen(".profiles", "r");
  while (fgets(buf, 1024, fp)) {
    sscanf(buf, "%s", inputLine);
    testUname = strtok(inputLine, ",");
    testHostname = strtok(NULL, "\0");
    if ((strcmp(testUname, uname) == 0) && strcmp(testHostname, hostname) == 0)
      profileExists = 1;
    else {
      inputLine = calloc(80, sizeof(char));
      testUname = calloc(30, sizeof(char));
      testHostname = calloc(50, sizeof(char));
    }
  }
  fclose(fp);
  if (profileExists == 0) {
    char *cmd = malloc(120);
    assert(cmd);
    cmd[0] = '\0';
    char *pre = "echo ";
    char *post = " | tee -a .profiles > /dev/null";
    cmd = strcat(cmd, pre);
    cmd = strcat(cmd, uname);
    cmd = strcat(cmd, ",");
    cmd = strcat(cmd, hostname);
    cmd = strcat(cmd, post);
    system(cmd);
    free(cmd);
  }
  return profileExists;
}


x86 assembly (clang, -O0):
<checkProfiles>:
push   %rbp
mov    %rsp,%rbp
sub    $0x850,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    $0x50,%edi
mov    $0x1,%esi
call   1070 <calloc@plt>
mov    %rax,-0x828(%rbp)
mov    -0x828(%rbp),%rdi
call   1090 <assert@plt>
mov    $0x1e,%edi
mov    $0x1,%esi
call   1070 <calloc@plt>
mov    %rax,-0x830(%rbp)
mov    -0x830(%rbp),%rdi
call   1090 <assert@plt>
mov    $0x32,%edi
mov    $0x1,%esi
call   1070 <calloc@plt>
mov    %rax,-0x838(%rbp)
mov    -0x838(%rbp),%rdi
call   1090 <assert@plt>
lea    0xdbd(%rip),%rdi
lea    0xdc0(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x20(%rbp)
lea    -0x820(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x400,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     1344 <checkProfiles+0x184>
lea    -0x820(%rbp),%rdi
mov    -0x828(%rbp),%rdx
lea    0xd85(%rip),%rsi
call   10b0 <sscanf@plt>
mov    -0x828(%rbp),%rdi
lea    0xd75(%rip),%rsi
call   10d0 <strtok@plt>
mov    %rax,-0x830(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xd86(%rip),%rsi
call   10d0 <strtok@plt>
mov    %rax,-0x838(%rbp)
mov    -0x830(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    12fd <checkProfiles+0x13d>
mov    -0x838(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    12fd <checkProfiles+0x13d>
movl   $0x1,-0x4(%rbp)
jmp    133f <checkProfiles+0x17f>
mov    $0x50,%edi
mov    $0x1,%esi
call   1070 <calloc@plt>
mov    %rax,-0x828(%rbp)
mov    $0x1e,%edi
mov    $0x1,%esi
call   1070 <calloc@plt>
mov    %rax,-0x830(%rbp)
mov    $0x32,%edi
mov    $0x1,%esi
call   1070 <calloc@plt>
mov    %rax,-0x838(%rbp)
jmp    1253 <checkProfiles+0x93>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
cmpl   $0x0,-0x4(%rbp)
jne    142e <checkProfiles+0x26e>
mov    $0x78,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x840(%rbp)
mov    -0x840(%rbp),%rdi
call   1090 <assert@plt>
mov    -0x840(%rbp),%rax
movb   $0x0,(%rax)
lea    0xc8c(%rip),%rax
mov    %rax,-0x848(%rbp)
lea    0xc84(%rip),%rax
mov    %rax,-0x850(%rbp)
mov    -0x840(%rbp),%rdi
mov    -0x848(%rbp),%rsi
call   10e0 <strcat@plt>
mov    %rax,-0x840(%rbp)
mov    -0x840(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   10e0 <strcat@plt>
mov    %rax,-0x840(%rbp)
mov    -0x840(%rbp),%rdi
lea    0xc36(%rip),%rsi
call   10e0 <strcat@plt>
mov    %rax,-0x840(%rbp)
mov    -0x840(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   10e0 <strcat@plt>
mov    %rax,-0x840(%rbp)
mov    -0x840(%rbp),%rdi
mov    -0x850(%rbp),%rsi
call   10e0 <strcat@plt>
mov    %rax,-0x840(%rbp)
mov    -0x840(%rbp),%rdi
call   1050 <system@plt>
mov    -0x840(%rbp),%rdi
call   1030 <free@plt>
mov    -0x4(%rbp),%eax
add    $0x850,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkProfiles>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x818,%rsp
mov    %rdx,0x8(%rsp)
mov    %rsi,%r12
mov    %edi,0x4(%rsp)
mov    $0x50,%edi
mov    $0x1,%esi
call   1080 <calloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   10a0 <assert@plt>
mov    $0x1e,%edi
mov    $0x1,%esi
call   1080 <calloc@plt>
mov    %rax,%rdi
call   10a0 <assert@plt>
mov    $0x32,%edi
mov    $0x1,%esi
call   1080 <calloc@plt>
mov    %rax,%rdi
call   10a0 <assert@plt>
lea    0xdc4(%rip),%rdi
lea    0xdc7(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,%rbp
lea    0x10(%rsp),%rdi
mov    $0x400,%esi
mov    %rax,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     12f8 <checkProfiles+0x128>
lea    0x10(%rsp),%r14
jmp    1297 <checkProfiles+0xc7>
nopl   (%rax)
mov    $0x50,%edi
mov    $0x1,%esi
call   1080 <calloc@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    $0x400,%esi
mov    %rbp,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     12f8 <checkProfiles+0x128>
mov    %r14,%rdi
lea    0xd6b(%rip),%rsi
mov    %rbx,%rdx
call   10c0 <sscanf@plt>
mov    %rbx,%rdi
lea    0xd5c(%rip),%rsi
call   10e0 <strtok@plt>
mov    %rax,%r13
xor    %edi,%edi
lea    0xd73(%rip),%rsi
call   10e0 <strtok@plt>
mov    %rax,%r15
mov    %r13,%rdi
mov    %r12,%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
jne    1270 <checkProfiles+0xa0>
mov    %r15,%rdi
mov    0x8(%rsp),%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
jne    1270 <checkProfiles+0xa0>
movl   $0x1,0x4(%rsp)
jmp    1282 <checkProfiles+0xb2>
mov    %rbp,%rdi
call   1040 <fclose@plt>
mov    0x4(%rsp),%ebp
test   %ebp,%ebp
jne    138f <checkProfiles+0x1bf>
mov    $0x78,%edi
call   10b0 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   10a0 <assert@plt>
movb   $0x0,(%rbx)
mov    %rbx,%rdi
call   1050 <strlen@plt>
movl   $0x6f686365,(%rbx,%rax,1)
movw   $0x20,0x4(%rbx,%rax,1)
mov    %rbx,%rdi
mov    %r12,%rsi
call   10f0 <strcat@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
movw   $0x2c,(%rbx,%rax,1)
mov    %rbx,%rdi
mov    0x8(%rsp),%rsi
call   10f0 <strcat@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
movups 0xca8(%rip),%xmm0
movups %xmm0,(%rbx,%rax,1)
movups 0xcad(%rip),%xmm0
movups %xmm0,0x10(%rbx,%rax,1)
mov    %rbx,%rdi
call   1060 <system@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x818,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c".profiles\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [2 x i8] c",\00"
@.str.4 = [2 x i8] zeroinitializer
@.str.5 = [6 x i8] c"echo \00"
@.str.6 = [32 x i8] c" | tee -a .profiles > /dev/null\00"
define i32 @checkProfiles(i32 %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca [2048 x i8]
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
store i32 %0, i32* %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%15 = call i8* @calloc(i32 80, i32 1)
store i8* %15, i8** %9
%16 = load i8*, i8** %9
%17 = call i32 @assert(i8* %16)
%18 = call i8* @calloc(i32 30, i32 1)
store i8* %18, i8** %10
%19 = load i8*, i8** %10
%20 = call i32 @assert(i8* %19)
%21 = call i8* @calloc(i32 50, i32 1)
store i8* %21, i8** %11
%22 = load i8*, i8** %11
%23 = call i32 @assert(i8* %22)
%24 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %24, i32** %7
br label %25
25: ; preds = %51, %3
%26 = getelementptr inbounds [2048 x i8], [2048 x i8]* %8, i64 0, i64 0
%27 = load i32*, i32** %7
%28 = call i64 @fgets(i8* %26, i32 1024, i32* %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %52
30: ; preds = %25
%31 = getelementptr inbounds [2048 x i8], [2048 x i8]* %8, i64 0, i64 0
%32 = load i8*, i8** %9
%33 = call i32 @sscanf(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %32)
%34 = load i8*, i8** %9
%35 = call i8* @strtok(i8* %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i8* %35, i8** %10
%36 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i8* %36, i8** %11
%37 = load i8*, i8** %10
%38 = load i8*, i8** %5
%39 = call i64 @strcmp(i8* %37, i8* %38)
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %47
41: ; preds = %30
%42 = load i8*, i8** %11
%43 = load i8*, i8** %6
%44 = call i64 @strcmp(i8* %42, i8* %43)
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %47
46: ; preds = %41
store i32 1, i32* %4
br label %51
47: ; preds = %41, %30
%48 = call i8* @calloc(i32 80, i32 1)
store i8* %48, i8** %9
%49 = call i8* @calloc(i32 30, i32 1)
store i8* %49, i8** %10
%50 = call i8* @calloc(i32 50, i32 1)
store i8* %50, i8** %11
br label %51
51: ; preds = %47, %46
br label %25
52: ; preds = %25
%53 = load i32*, i32** %7
%54 = call i32 @fclose(i32* %53)
%55 = load i32, i32* %4
%56 = icmp eq i32 %55, 0
br i1 %56, label %57, label %81
57: ; preds = %52
%58 = call i8* @malloc(i32 120)
store i8* %58, i8** %12
%59 = load i8*, i8** %12
%60 = call i32 @assert(i8* %59)
%61 = load i8*, i8** %12
%62 = getelementptr inbounds i8, i8* %61, i64 0
store i8 0, i8* %62
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8** %13
store i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i8** %14
%63 = load i8*, i8** %12
%64 = load i8*, i8** %13
%65 = call i8* @strcat(i8* %63, i8* %64)
store i8* %65, i8** %12
%66 = load i8*, i8** %12
%67 = load i8*, i8** %5
%68 = call i8* @strcat(i8* %66, i8* %67)
store i8* %68, i8** %12
%69 = load i8*, i8** %12
%70 = call i8* @strcat(i8* %69, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i8* %70, i8** %12
%71 = load i8*, i8** %12
%72 = load i8*, i8** %6
%73 = call i8* @strcat(i8* %71, i8* %72)
store i8* %73, i8** %12
%74 = load i8*, i8** %12
%75 = load i8*, i8** %14
%76 = call i8* @strcat(i8* %74, i8* %75)
store i8* %76, i8** %12
%77 = load i8*, i8** %12
%78 = call i32 @system(i8* %77)
%79 = load i8*, i8** %12
%80 = call i32 @free(i8* %79)
br label %81
81: ; preds = %57, %52
%82 = load i32, i32* %4
ret i32 %82
}

LLVM IR (-O2):
@.str = [10 x i8] c".profiles\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [2 x i8] c",\00"
@.str.4 = [2 x i8] zeroinitializer
@.str.5 = [6 x i8] c"echo \00"
@.str.6 = [32 x i8] c" | tee -a .profiles > /dev/null\00"
define i32 @checkProfiles(i32 %0, i8* %1, i8* %2) {
%4 = alloca [2048 x i8]
%5 = getelementptr inbounds [2048 x i8], [2048 x i8]* %4, i64 0, i64 0
%6 = tail call dereferenceable_or_null(80) i8* @calloc(i32 80, i32 1)
%7 = tail call i32 @assert(i8* %6)
%8 = tail call dereferenceable_or_null(30) i8* @calloc(i32 30, i32 1)
%9 = tail call i32 @assert(i8* %8)
%10 = tail call dereferenceable_or_null(50) i8* @calloc(i32 50, i32 1)
%11 = tail call i32 @assert(i8* %10)
%12 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = call i64 @fgets(i8* %5, i32 1024, i32* %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %33, label %15
15: ; preds = %3, %28
%16 = phi i32 [ %30, %28 ], [ %0, %3 ]
%17 = phi i8* [ %29, %28 ], [ %6, %3 ]
%18 = call i32 @sscanf(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %17)
%19 = call i8* @strtok(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%20 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%21 = call i64 @strcmp(i8* %19, i8* %1)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %15
%24 = call i64 @strcmp(i8* %20, i8* %2)
%25 = icmp eq i64 %24, 0
br i1 %25, label %28, label %26
26: ; preds = %23, %15
%27 = call dereferenceable_or_null(80) i8* @calloc(i32 80, i32 1)
br label %28
28: ; preds = %23, %26
%29 = phi i8* [ %27, %26 ], [ %17, %23 ]
%30 = phi i32 [ %16, %26 ], [ 1, %23 ]
%31 = call i64 @fgets(i8* %5, i32 1024, i32* %12)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %15
33: ; preds = %28, %3
%34 = phi i32 [ %0, %3 ], [ %30, %28 ]
%35 = call i32 @fclose(i32* %12)
%36 = icmp eq i32 %34, 0
br i1 %36, label %37, label %51
37: ; preds = %33
%38 = call dereferenceable_or_null(120) i8* @malloc(i32 120)
%39 = call i32 @assert(i8* %38)
store i8 0, i8* %38
%40 = call i64 @strlen(i8* %38)
%41 = getelementptr i8, i8* %38, i64 %40
%42 = call i8* @strcat(i8* %38, i8* dereferenceable(1) %1)
%43 = call i64 @strlen(i8* %38)
%44 = getelementptr i8, i8* %38, i64 %43
%45 = bitcast i8* %44 to i16*
store i16 44, i16* %45
%46 = call i8* @strcat(i8* %38, i8* dereferenceable(1) %2)
%47 = call i64 @strlen(i8* %38)
%48 = getelementptr i8, i8* %38, i64 %47
%49 = call i32 @system(i8* %38)
%50 = call i32 @free(i8* %38)
br label %51
51: ; preds = %37, %33
ret i32 %34
}