#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 */
scalar_t__ anagram(char *, char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, char *);
char *malloc(int);
int /*<<< orphan*/ printf(char *, char *, char *);
int main() {
  FILE *file_ptr = fopen("test.txt", "r");
  if (file_ptr == NULL)
    return 1;
  char *string1 = malloc(256);
  char *string2 = malloc(256);
  fscanf(file_ptr, "%s", string1);
  fscanf(file_ptr, "%s", string2);
  fclose(file_ptr);
  if (anagram(string1, string2))
    printf("%s is an anagram of %s\n", string1, string2);
  else
    printf("%s is not an anagram of %s\n", string1, string2);
  free(string1);
  free(string2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe7a(%rip),%rdi
lea    0xe7c(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11ad <main+0x3d>
movl   $0x1,-0x4(%rbp)
jmp    1257 <main+0xe7>
mov    $0x100,%edi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    $0x100,%edi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe33(%rip),%rsi
call   1060 <fscanf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xe1f(%rip),%rsi
call   1060 <fscanf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1080 <anagram@plt>
cmp    $0x0,%rax
je     122a <main+0xba>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xdee(%rip),%rdi
call   1050 <printf@plt>
jmp    123e <main+0xce>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xded(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xe81(%rip),%rdi
lea    0xe83(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     121b <main+0xab>
mov    %rax,%rbx
mov    $0x100,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
mov    $0x100,%edi
call   1070 <malloc@plt>
mov    %rax,%r15
lea    0xe53(%rip),%r12
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
call   1060 <fscanf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
call   1060 <fscanf@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1080 <anagram@plt>
test   %rax,%rax
lea    0xe35(%rip),%rax
lea    0xe16(%rip),%rdi
cmove  %rax,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1050 <printf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
xor    %eax,%eax
jmp    1220 <main+0xb0>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [9 x i8] c"test.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [24 x i8] c"%s is an anagram of %s\0A\00"
@.str.4 = [28 x i8] c"%s is not an anagram of %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i8*
%4 = alloca i8*
store i32 0, i32* %1
%5 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %5, i32** %2
%6 = load i32*, i32** %2
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %9
8: ; preds = %0
store i32 1, i32* %1
br label %37
9: ; preds = %0
%10 = call i8* @malloc(i32 256)
store i8* %10, i8** %3
%11 = call i8* @malloc(i32 256)
store i8* %11, i8** %4
%12 = load i32*, i32** %2
%13 = load i8*, i8** %3
%14 = call i32 @fscanf(i32* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %13)
%15 = load i32*, i32** %2
%16 = load i8*, i8** %4
%17 = call i32 @fscanf(i32* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %16)
%18 = load i32*, i32** %2
%19 = call i32 @fclose(i32* %18)
%20 = load i8*, i8** %3
%21 = load i8*, i8** %4
%22 = call i64 @anagram(i8* %20, i8* %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %28
24: ; preds = %9
%25 = load i8*, i8** %3
%26 = load i8*, i8** %4
%27 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %25, i8* %26)
br label %32
28: ; preds = %9
%29 = load i8*, i8** %3
%30 = load i8*, i8** %4
%31 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i8* %29, i8* %30)
br label %32
32: ; preds = %28, %24
%33 = load i8*, i8** %3
%34 = call i32 @free(i8* %33)
%35 = load i8*, i8** %4
%36 = call i32 @free(i8* %35)
store i32 0, i32* %1
br label %37
37: ; preds = %32, %8
%38 = load i32, i32* %1
ret i32 %38
}

LLVM IR (-O2):
@.str = [9 x i8] c"test.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [24 x i8] c"%s is an anagram of %s\0A\00"
@.str.4 = [28 x i8] c"%s is not an anagram of %s\0A\00"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%2 = icmp eq i32* %1, null
br i1 %2, label %15, label %3
3: ; preds = %0
%4 = tail call dereferenceable_or_null(256) i8* @malloc(i32 256)
%5 = tail call dereferenceable_or_null(256) i8* @malloc(i32 256)
%6 = tail call i32 @fscanf(i32* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%7 = tail call i32 @fscanf(i32* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%8 = tail call i32 @fclose(i32* %1)
%9 = tail call i64 @anagram(i8* %4, i8* %5)
%10 = icmp eq i64 %9, 0
%11 = select i1 %10, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0)
%12 = tail call i32 @printf(i8* %11, i8* %4, i8* %5)
%13 = tail call i32 @free(i8* %4)
%14 = tail call i32 @free(i8* %5)
br label %15
15: ; preds = %0, %3
%16 = phi i32 [ 0, %3 ], [ 1, %0 ]
ret i32 %16
}