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

/* Variables and functions */
scalar_t__ MAP_FAILED;
int /*<<< orphan*/ MAP_SHARED;
int /*<<< orphan*/ O_RDWR;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
int /*<<< orphan*/ getpid();
scalar_t__ ioctl(int, int, unsigned long *);
int /*<<< orphan*/ lseek(int, int /*<<< orphan*/, int /*<<< orphan*/);
char *malloc(unsigned long);
char *mmap(int /*<<< orphan*/ *, unsigned long, int, int /*<<< orphan*/, int,
           int /*<<< orphan*/);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
unsigned long random();
int /*<<< orphan*/ read_and_compare(int, char *, char *, unsigned long);
int /*<<< orphan*/ srandom(int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int main(int argc, char **argv) {
  unsigned long j, len;
  int fd;
  char *read_buf, *mmap_buf, *filename = "/dev/mycdrv";
  srandom(getpid());
  if (argc > 1)
    filename = argv[1];
  if ((fd = open(filename, O_RDWR)) < 0) {
    fprintf(stderr, "open of %s failed:  %s\n", filename, strerror(errno));
    exit(1);
  }
  if (ioctl(fd, 1, &len) < 0) {
    fprintf(stderr, "ioctl failed:  %s\n", strerror(errno));
    exit(1);
  }
  printf("driver's ioctl says buffer size is %ld\n", len);
  read_buf = malloc(len);
  mmap_buf = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
  if (mmap_buf == (char *)MAP_FAILED) {
    fprintf(stderr, "mmap of %s failed:  %s\n", filename, strerror(errno));
    exit(1);
  }
  printf("mmap succeeded:  %p\n", mmap_buf);
  for (j = 0; j < len; j++)
    *(mmap_buf + j) = (char)j;
  read_and_compare(fd, read_buf, mmap_buf, len);
  printf("comparison of same data via read() and mmap() successful\n");
  j = random() % len;
  *(mmap_buf + j) = random() % j;
  (void)lseek(fd, 0, SEEK_SET);
  read_and_compare(fd, read_buf, mmap_buf, len);
  printf("comparison of modified data via read() and mmap() successful\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe13(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,%edi
call   1030 <srandom@plt>
cmpl   $0x1,-0x8(%rbp)
jle    1215 <main+0x45>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
mov    0x2db8(%rip),%rax
mov    (%rax),%esi
call   10d0 <open@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
jge    1277 <main+0xa7>
mov    0x2d8e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    0x2d72(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    -0x4c(%rbp),%edi
mov    -0x48(%rbp),%rdx
mov    %rax,%rcx
lea    0xda6(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x24(%rbp),%edi
mov    $0x1,%esi
lea    -0x20(%rbp),%rdx
call   1080 <ioctl@plt>
cmp    $0x0,%rax
jge    12ca <main+0xfa>
mov    0x2d2f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x50(%rbp)
mov    0x2d1b(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    -0x50(%rbp),%edi
mov    %rax,%rdx
lea    0xd6b(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x20(%rbp),%rsi
lea    0xd62(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdi
call   10b0 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rsi
mov    0x2d04(%rip),%rax
mov    (%rax),%edx
mov    0x2cb3(%rip),%rax
or     (%rax),%edx
mov    0x2ce2(%rip),%rax
mov    (%rax),%ecx
mov    -0x24(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
xor    %r9d,%r9d
call   1050 <mmap@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    0x2c81(%rip),%rcx
mov    (%rcx),%rcx
cmp    %rcx,%rax
jne    1377 <main+0x1a7>
mov    0x2c8e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x5c(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    0x2c72(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    -0x5c(%rbp),%edi
mov    -0x58(%rbp),%rdx
mov    %rax,%rcx
lea    0xcf9(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x38(%rbp),%rsi
lea    0xcf5(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    13c1 <main+0x1f1>
mov    -0x18(%rbp),%rax
mov    %al,%dl
mov    -0x38(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1391 <main+0x1c1>
mov    -0x24(%rbp),%edi
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   10c0 <read_and_compare@plt>
lea    0xcb0(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   10a0 <random@plt>
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x20(%rbp)
mov    %rdx,-0x18(%rbp)
mov    $0x0,%al
call   10a0 <random@plt>
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x18(%rbp)
mov    -0x38(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x24(%rbp),%edi
mov    0x2b9e(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1070 <lseek@plt>
mov    -0x24(%rbp),%edi
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   10c0 <read_and_compare@plt>
lea    0xc88(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %eax,%eax
call   1050 <getpid@plt>
mov    %eax,%edi
call   1030 <srandom@plt>
cmp    $0x2,%ebp
jl     120a <main+0x2a>
mov    0x8(%rbx),%r15
jmp    1211 <main+0x31>
lea    0xdef(%rip),%r15
mov    0x2dc0(%rip),%rax
mov    (%rax),%esi
mov    %r15,%rdi
call   10e0 <open@plt>
test   %eax,%eax
js     1388 <main+0x1a8>
mov    %eax,%r12d
lea    0x8(%rsp),%rdx
mov    %eax,%edi
mov    $0x1,%esi
call   1090 <ioctl@plt>
test   %rax,%rax
js     13a8 <main+0x1c8>
mov    0x8(%rsp),%rsi
lea    0xde4(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   10c0 <malloc@plt>
mov    %rax,%r14
mov    0x2d87(%rip),%rax
mov    0x2d38(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2d65(%rip),%rax
mov    (%rax),%ecx
xor    %edi,%edi
mov    %rbx,%rsi
mov    %r12d,%r8d
xor    %r9d,%r9d
call   1060 <mmap@plt>
mov    %rax,%rbx
mov    0x2d09(%rip),%rax
cmp    (%rax),%rbx
je     13dc <main+0x1fc>
lea    0xdc8(%rip),%rdi
xor    %ebp,%ebp
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
cmpq   $0x0,0x8(%rsp)
je     12e1 <main+0x101>
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nop
mov    %al,(%rbx,%rax,1)
add    $0x1,%rax
mov    0x8(%rsp),%rbp
cmp    %rbp,%rax
jb     12d0 <main+0xf0>
mov    %r12d,%edi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %rbp,%rcx
call   10d0 <read_and_compare@plt>
lea    0xd93(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   10b0 <random@plt>
mov    0x8(%rsp),%rcx
mov    %rax,%rdx
or     %rcx,%rdx
shr    $0x20,%rdx
je     1320 <main+0x140>
xor    %edx,%edx
div    %rcx
mov    %rdx,%rbp
jmp    1326 <main+0x146>
xor    %edx,%edx
div    %ecx
mov    %edx,%ebp
xor    %eax,%eax
call   10b0 <random@plt>
mov    %rax,%rcx
or     %rbp,%rcx
shr    $0x20,%rcx
je     1340 <main+0x160>
xor    %edx,%edx
div    %rbp
jmp    1344 <main+0x164>
xor    %edx,%edx
div    %ebp
mov    %dl,(%rbx,%rbp,1)
mov    0x2c6a(%rip),%rax
mov    (%rax),%edx
mov    %r12d,%edi
xor    %esi,%esi
call   1080 <lseek@plt>
mov    0x8(%rsp),%rcx
mov    %r12d,%edi
mov    %r14,%rsi
mov    %rbx,%rdx
call   10d0 <read_and_compare@plt>
lea    0xd51(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c39(%rip),%rax
mov    (%rax),%ebx
mov    0x2c28(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
lea    0xc66(%rip),%rsi
jmp    13fa <main+0x21a>
mov    0x2c19(%rip),%rax
mov    (%rax),%ebx
mov    0x2c08(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
lea    0xc5e(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    0x2be5(%rip),%rax
mov    (%rax),%ebx
mov    0x2bd4(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
lea    0xc65(%rip),%rsi
mov    %ebx,%edi
mov    %r15,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"/dev/mycdrv\00"
@O_RDWR = global i32 0
@stderr = global i32 0
@.str.1 = [24 x i8] c"open of %s failed: %s\0A\00"
@errno = global i32 0
@.str.2 = [19 x i8] c"ioctl failed: %s\0A\00"
@.str.3 = [40 x i8] c"driver's ioctl says buffer size is %ld\0A\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@MAP_FAILED = global i64 0
@.str.4 = [24 x i8] c"mmap of %s failed: %s\0A\00"
@.str.5 = [21 x i8] c"mmap succeeded: %p\0A\00"
@.str.6 = [58 x i8] c"comparison of same data via read() and mmap() successful\0A\00"
@SEEK_SET = global i32 0
@.str.7 = [62 x i8] c"comparison of modified data via read() and mmap() successful\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %11
%12 = call i32 (...) @getpid()
%13 = call i32 @srandom(i32 %12)
%14 = load i32, i32* %4
%15 = icmp sgt i32 %14, 1
br i1 %15, label %16, label %20
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
store i8* %19, i8** %11
br label %20
20: ; preds = %16, %2
%21 = load i8*, i8** %11
%22 = load i32, i32* @O_RDWR
%23 = call i32 @open(i8* %21, i32 %22)
store i32 %23, i32* %8
%24 = icmp slt i32 %23, 0
br i1 %24, label %25, label %32
25: ; preds = %20
%26 = load i32, i32* @stderr
%27 = load i8*, i8** %11
%28 = load i32, i32* @errno
%29 = call i8* @strerror(i32 %28)
%30 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %27, i8* %29)
%31 = call i32 @exit(i32 1)
unreachable
32: ; preds = %20
%33 = load i32, i32* %8
%34 = call i64 @ioctl(i32 %33, i32 1, i64* %7)
%35 = icmp slt i64 %34, 0
br i1 %35, label %36, label %42
36: ; preds = %32
%37 = load i32, i32* @stderr
%38 = load i32, i32* @errno
%39 = call i8* @strerror(i32 %38)
%40 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %39)
%41 = call i32 @exit(i32 1)
unreachable
42: ; preds = %32
%43 = load i64, i64* %7
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i64 %43)
%45 = load i64, i64* %7
%46 = call i8* @malloc(i64 %45)
store i8* %46, i8** %9
%47 = load i64, i64* %7
%48 = load i32, i32* @PROT_READ
%49 = load i32, i32* @PROT_WRITE
%50 = or i32 %48, %49
%51 = load i32, i32* @MAP_SHARED
%52 = load i32, i32* %8
%53 = call i8* @mmap(i32* null, i64 %47, i32 %50, i32 %51, i32 %52, i32 0)
store i8* %53, i8** %10
%54 = load i8*, i8** %10
%55 = load i64, i64* @MAP_FAILED
%56 = inttoptr i64 %55 to i8*
%57 = icmp eq i8* %54, %56
br i1 %57, label %58, label %65
58: ; preds = %42
%59 = load i32, i32* @stderr
%60 = load i8*, i8** %11
%61 = load i32, i32* @errno
%62 = call i8* @strerror(i32 %61)
%63 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %59, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %60, i8* %62)
%64 = call i32 @exit(i32 1)
unreachable
65: ; preds = %42
%66 = load i8*, i8** %10
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i8* %66)
store i64 0, i64* %6
br label %68
68: ; preds = %78, %65
%69 = load i64, i64* %6
%70 = load i64, i64* %7
%71 = icmp ult i64 %69, %70
br i1 %71, label %72, label %81
72: ; preds = %68
%73 = load i64, i64* %6
%74 = trunc i64 %73 to i8
%75 = load i8*, i8** %10
%76 = load i64, i64* %6
%77 = getelementptr inbounds i8, i8* %75, i64 %76
store i8 %74, i8* %77
br label %78
78: ; preds = %72
%79 = load i64, i64* %6
%80 = add i64 %79, 1
store i64 %80, i64* %6
br label %68
81: ; preds = %68
%82 = load i32, i32* %8
%83 = load i8*, i8** %9
%84 = load i8*, i8** %10
%85 = load i64, i64* %7
%86 = call i32 @read_and_compare(i32 %82, i8* %83, i8* %84, i64 %85)
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.6, i64 0, i64 0))
%88 = call i64 (...) @random()
%89 = load i64, i64* %7
%90 = urem i64 %88, %89
store i64 %90, i64* %6
%91 = call i64 (...) @random()
%92 = load i64, i64* %6
%93 = urem i64 %91, %92
%94 = trunc i64 %93 to i8
%95 = load i8*, i8** %10
%96 = load i64, i64* %6
%97 = getelementptr inbounds i8, i8* %95, i64 %96
store i8 %94, i8* %97
%98 = load i32, i32* %8
%99 = load i32, i32* @SEEK_SET
%100 = call i32 @lseek(i32 %98, i32 0, i32 %99)
%101 = load i32, i32* %8
%102 = load i8*, i8** %9
%103 = load i8*, i8** %10
%104 = load i64, i64* %7
%105 = call i32 @read_and_compare(i32 %101, i8* %102, i8* %103, i64 %104)
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.7, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"/dev/mycdrv\00"
@O_RDWR = global i32 0
@stderr = global i32 0
@.str.1 = [24 x i8] c"open of %s failed: %s\0A\00"
@errno = global i32 0
@.str.2 = [19 x i8] c"ioctl failed: %s\0A\00"
@.str.3 = [40 x i8] c"driver's ioctl says buffer size is %ld\0A\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@MAP_FAILED = global i64 0
@.str.4 = [24 x i8] c"mmap of %s failed: %s\0A\00"
@.str.5 = [21 x i8] c"mmap succeeded: %p\0A\00"
@SEEK_SET = global i32 0
@str = [57 x i8] c"comparison of same data via read() and mmap() successful\00"
@str.8 = [61 x i8] c"comparison of modified data via read() and mmap() successful\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to i8*
%5 = tail call i32 (...) @getpid()
%6 = tail call i32 @srandom(i32 %5)
%7 = icmp sgt i32 %0, 1
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
br label %11
11: ; preds = %8, %2
%12 = phi i8* [ %10, %8 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), %2 ]
%13 = load i32, i32* @O_RDWR
%14 = tail call i32 @open(i8* %12, i32 %13)
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %22
16: ; preds = %11
%17 = load i32, i32* @stderr
%18 = load i32, i32* @errno
%19 = tail call i8* @strerror(i32 %18)
%20 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %12, i8* %19)
%21 = tail call i32 @exit(i32 1)
unreachable
22: ; preds = %11
%23 = call i64 @ioctl(i32 %14, i32 1, i64* %3)
%24 = icmp slt i64 %23, 0
br i1 %24, label %25, label %31
25: ; preds = %22
%26 = load i32, i32* @stderr
%27 = load i32, i32* @errno
%28 = call i8* @strerror(i32 %27)
%29 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %28)
%30 = call i32 @exit(i32 1)
unreachable
31: ; preds = %22
%32 = load i64, i64* %3
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i64 %32)
%34 = load i64, i64* %3
%35 = call i8* @malloc(i64 %34)
%36 = load i32, i32* @PROT_READ
%37 = load i32, i32* @PROT_WRITE
%38 = or i32 %37, %36
%39 = load i32, i32* @MAP_SHARED
%40 = call i8* @mmap(i32* null, i64 %34, i32 %38, i32 %39, i32 %14, i32 0)
%41 = load i64, i64* @MAP_FAILED
%42 = inttoptr i64 %41 to i8*
%43 = icmp eq i8* %40, %42
br i1 %43, label %44, label %50
44: ; preds = %31
%45 = load i32, i32* @stderr
%46 = load i32, i32* @errno
%47 = call i8* @strerror(i32 %46)
%48 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %12, i8* %47)
%49 = call i32 @exit(i32 1)
unreachable
50: ; preds = %31
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i8* %40)
%52 = load i64, i64* %3
%53 = icmp eq i64 %52, 0
br i1 %53, label %61, label %54
54: ; preds = %50, %54
%55 = phi i64 [ %58, %54 ], [ 0, %50 ]
%56 = trunc i64 %55 to i8
%57 = getelementptr inbounds i8, i8* %40, i64 %55
store i8 %56, i8* %57
%58 = add nuw i64 %55, 1
%59 = load i64, i64* %3
%60 = icmp ult i64 %58, %59
br i1 %60, label %54, label %61
61: ; preds = %54, %50
%62 = phi i64 [ 0, %50 ], [ %59, %54 ]
%63 = call i32 @read_and_compare(i32 %14, i8* %35, i8* %40, i64 %62)
%64 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str, i64 0, i64 0))
%65 = call i64 (...) @random()
%66 = load i64, i64* %3
%67 = urem i64 %65, %66
%68 = call i64 (...) @random()
%69 = urem i64 %68, %67
%70 = trunc i64 %69 to i8
%71 = getelementptr inbounds i8, i8* %40, i64 %67
store i8 %70, i8* %71
%72 = load i32, i32* @SEEK_SET
%73 = call i32 @lseek(i32 %14, i32 0, i32 %72)
%74 = load i64, i64* %3
%75 = call i32 @read_and_compare(i32 %14, i8* %35, i8* %40, i64 %74)
%76 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @str.8, i64 0, i64 0))
ret i32 0
}