#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*/ abort();
int /*<<< orphan*/ fgets(char *, size_t, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, size_t *);
scalar_t__ malloc(size_t);
int /*<<< orphan*/ stderr;
int read_input_strings(char *filename, char **string_1, char **string_2) {
  FILE *file = fopen(filename, "r");
  if (!file) {
    fprintf(stderr, "Failed to open file.\n");
    abort();
  }
  size_t string_size;
  fscanf(file, "%zu%*c", &string_size);
  string_size += 2;
  *string_1 = (char *)malloc((string_size + 1) * sizeof(char));
  fgets(*string_1, string_size, file);
  (*string_1)[string_size - 2] = '\0';
  *string_2 = (char *)malloc((string_size + 1) * sizeof(char));
  fgets(*string_2, string_size, file);
  (*string_2)[string_size - 2] = '\0';
  return string_size;
}


x86 assembly (clang, -O0):
<read_input_strings>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe81(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11af <read_input_strings+0x4f>
mov    0x2e46(%rip),%rax
mov    (%rax),%edi
lea    0xe5f(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x20(%rbp),%rdi
lea    0xe5e(%rip),%rsi
lea    -0x28(%rbp),%rdx
call   1040 <fscanf@plt>
mov    -0x28(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
add    $0x1,%rdi
shl    $0x0,%rdi
call   1070 <malloc@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1050 <fgets@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x28(%rbp),%rcx
sub    $0x2,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x28(%rbp),%rdi
add    $0x1,%rdi
shl    $0x0,%rdi
call   1070 <malloc@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1050 <fgets@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    -0x28(%rbp),%rcx
sub    $0x2,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_input_strings>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
lea    0xe8a(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     120e <read_input_strings+0xae>
mov    %rax,%rbx
lea    0xe8a(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %rax,%rdi
call   1040 <fscanf@plt>
mov    0x8(%rsp),%rdi
lea    0x2(%rdi),%rax
mov    %rax,0x8(%rsp)
add    $0x3,%rdi
call   1070 <malloc@plt>
mov    %rax,(%r15)
mov    0x8(%rsp),%rsi
mov    %rax,%rdi
mov    %rbx,%rdx
call   1050 <fgets@plt>
mov    (%r15),%rax
mov    0x8(%rsp),%rcx
movb   $0x0,-0x2(%rcx,%rax,1)
mov    0x8(%rsp),%rdi
add    $0x1,%rdi
call   1070 <malloc@plt>
mov    %rax,(%r14)
mov    0x8(%rsp),%rsi
mov    %rax,%rdi
mov    %rbx,%rdx
call   1050 <fgets@plt>
mov    (%r14),%rax
mov    0x8(%rsp),%rcx
movb   $0x0,-0x2(%rcx,%rax,1)
mov    0x8(%rsp),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
mov    0x2dcb(%rip),%rax
mov    (%rax),%edi
lea    0xde4(%rip),%rsi
call   1060 <fprintf@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [22 x i8] c"Failed to open file.\0A\00"
@.str.2 = [7 x i8] c"%zu%*c\00"
define i32 @read_input_strings(i8* %0, i8** %1, i8** %2) {
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca i32*
%8 = alloca i64
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i8** %2, i8*** %6
%9 = load i8*, i8** %4
%10 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %10, i32** %7
%11 = load i32*, i32** %7
%12 = icmp ne i32* %11, null
br i1 %12, label %17, label %13
13: ; preds = %3
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 (...) @abort()
unreachable
17: ; preds = %3
%18 = load i32*, i32** %7
%19 = call i32 @fscanf(i32* %18, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i64* %8)
%20 = load i64, i64* %8
%21 = add i64 %20, 2
store i64 %21, i64* %8
%22 = load i64, i64* %8
%23 = add i64 %22, 1
%24 = mul i64 %23, 1
%25 = call i64 @malloc(i64 %24)
%26 = inttoptr i64 %25 to i8*
%27 = load i8**, i8*** %5
store i8* %26, i8** %27
%28 = load i8**, i8*** %5
%29 = load i8*, i8** %28
%30 = load i64, i64* %8
%31 = load i32*, i32** %7
%32 = call i32 @fgets(i8* %29, i64 %30, i32* %31)
%33 = load i8**, i8*** %5
%34 = load i8*, i8** %33
%35 = load i64, i64* %8
%36 = sub i64 %35, 2
%37 = getelementptr inbounds i8, i8* %34, i64 %36
store i8 0, i8* %37
%38 = load i64, i64* %8
%39 = add i64 %38, 1
%40 = mul i64 %39, 1
%41 = call i64 @malloc(i64 %40)
%42 = inttoptr i64 %41 to i8*
%43 = load i8**, i8*** %6
store i8* %42, i8** %43
%44 = load i8**, i8*** %6
%45 = load i8*, i8** %44
%46 = load i64, i64* %8
%47 = load i32*, i32** %7
%48 = call i32 @fgets(i8* %45, i64 %46, i32* %47)
%49 = load i8**, i8*** %6
%50 = load i8*, i8** %49
%51 = load i64, i64* %8
%52 = sub i64 %51, 2
%53 = getelementptr inbounds i8, i8* %50, i64 %52
store i8 0, i8* %53
%54 = load i64, i64* %8
%55 = trunc i64 %54 to i32
ret i32 %55
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [22 x i8] c"Failed to open file.\0A\00"
@.str.2 = [7 x i8] c"%zu%*c\00"
define i32 @read_input_strings(i8* nocapture %0, i8** nocapture %1, i8** nocapture %2) {
%4 = alloca i64
%5 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %11
7: ; preds = %3
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%10 = tail call i32 (...) @abort()
unreachable
11: ; preds = %3
%12 = bitcast i64* %4 to i8*
%13 = call i32 @fscanf(i32* %5, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i64* %4)
%14 = load i64, i64* %4
%15 = add i64 %14, 2
store i64 %15, i64* %4
%16 = add i64 %14, 3
%17 = call i64 @malloc(i64 %16)
%18 = inttoptr i64 %17 to i8*
store i8* %18, i8** %1
%19 = load i64, i64* %4
%20 = call i32 @fgets(i8* %18, i64 %19, i32* %5)
%21 = load i8*, i8** %1
%22 = load i64, i64* %4
%23 = add i64 %22, -2
%24 = getelementptr inbounds i8, i8* %21, i64 %23
store i8 0, i8* %24
%25 = load i64, i64* %4
%26 = add i64 %25, 1
%27 = call i64 @malloc(i64 %26)
%28 = inttoptr i64 %27 to i8*
store i8* %28, i8** %2
%29 = load i64, i64* %4
%30 = call i32 @fgets(i8* %28, i64 %29, i32* %5)
%31 = load i8*, i8** %2
%32 = load i64, i64* %4
%33 = add i64 %32, -2
%34 = getelementptr inbounds i8, i8* %31, i64 %33
store i8 0, i8* %34
%35 = load i64, i64* %4
%36 = trunc i64 %35 to i32
ret i32 %36
}