#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 skip_lines(int /*<<< orphan*/ *, int);
char *store_lines(int /*<<< orphan*/ *, int const);
char *read_solution_string(FILE *fp, int k, int len, int dim) {
  char *result;
  const int lines = dim + 5;
  int fail;
  if (k > 1)
    fail = skip_lines(fp, (k - 1) * lines);
  if (fail == 0) {
    fail = skip_lines(fp, 1);
    result = store_lines(fp, lines - 1);
  }
  return result;
}


x86 assembly (clang, -O0):
<read_solution_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x5,%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x1,-0xc(%rbp)
jle    115e <read_solution_string+0x3e>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
sub    $0x1,%esi
imul   -0x24(%rbp),%esi
call   1030 <skip_lines@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jne    118c <read_solution_string+0x6c>
mov    -0x8(%rbp),%rdi
mov    $0x1,%esi
call   1030 <skip_lines@plt>
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%esi
sub    $0x1,%esi
call   1040 <store_lines@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_solution_string>:
push   %r14
push   %rbx
push   %rax
mov    %ecx,%ebx
mov    %rdi,%r14
cmp    $0x2,%esi
jl     114b <read_solution_string+0x2b>
lea    0x5(%rbx),%eax
add    $0xffffffff,%esi
imul   %eax,%esi
mov    %r14,%rdi
call   1030 <skip_lines@plt>
test   %eax,%eax
je     114b <read_solution_string+0x2b>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    %r14,%rdi
mov    $0x1,%esi
call   1030 <skip_lines@plt>
add    $0x4,%ebx
mov    %r14,%rdi
mov    %ebx,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <store_lines@plt>

LLVM IR (-O0):
define i8* @read_solution_string(i32* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
store i32* %0, i32** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%12 = load i32, i32* %8
%13 = add nsw i32 %12, 5
store i32 %13, i32* %10
%14 = load i32, i32* %6
%15 = icmp sgt i32 %14, 1
br i1 %15, label %16, label %23
16: ; preds = %4
%17 = load i32*, i32** %5
%18 = load i32, i32* %6
%19 = sub nsw i32 %18, 1
%20 = load i32, i32* %10
%21 = mul nsw i32 %19, %20
%22 = call i32 @skip_lines(i32* %17, i32 %21)
store i32 %22, i32* %11
br label %23
23: ; preds = %16, %4
%24 = load i32, i32* %11
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %33
26: ; preds = %23
%27 = load i32*, i32** %5
%28 = call i32 @skip_lines(i32* %27, i32 1)
store i32 %28, i32* %11
%29 = load i32*, i32** %5
%30 = load i32, i32* %10
%31 = sub nsw i32 %30, 1
%32 = call i8* @store_lines(i32* %29, i32 %31)
store i8* %32, i8** %9
br label %33
33: ; preds = %26, %23
%34 = load i8*, i8** %9
ret i8* %34
}

LLVM IR (-O2):
define i8* @read_solution_string(i32* %0, i32 %1, i32 %2, i32 %3) {
%5 = icmp sgt i32 %1, 1
br i1 %5, label %6, label %12
6: ; preds = %4
%7 = add nsw i32 %3, 5
%8 = add nsw i32 %1, -1
%9 = mul nsw i32 %7, %8
%10 = tail call i32 @skip_lines(i32* %0, i32 %9)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %4, %6
%13 = tail call i32 @skip_lines(i32* %0, i32 1)
%14 = add nsw i32 %3, 4
%15 = tail call i8* @store_lines(i32* %0, i32 %14)
br label %16
16: ; preds = %12, %6
%17 = phi i8* [ %15, %12 ], [ undef, %6 ]
ret i8* %17
}