#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 */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ perror(char *);
scalar_t__ read(int, char *, int);
int write(int, char *, int);
void jvcwritesectors(int infd, int outfd, int ntrack, int nside, int nsec) {
  int i, j, k;
  static char buf[256];
  for (i = 0; i < ntrack; i++) {
    for (j = 0; j < nside; j++) {
      for (k = 1; k <= nsec; k++) {
        if (read(infd, buf, 256) < 0) {
          perror("read sectors");
          exit(1);
        }
        if (write(outfd, buf, 256) != 256) {
          perror("write jvc3");
          exit(1);
        }
      }
    }
  }
}


x86 assembly (clang, -O0):
<jvcwritesectors>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1233 <jvcwritesectors+0xf3>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1220 <jvcwritesectors+0xe0>
movl   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     120d <jvcwritesectors+0xcd>
mov    -0x4(%rbp),%edi
lea    0x2eb5(%rip),%rsi
mov    $0x100,%edx
call   1040 <read@plt>
cmp    $0x0,%rax
jge    11c5 <jvcwritesectors+0x85>
lea    0xe4a(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x8(%rbp),%edi
lea    0x2e81(%rip),%rsi
mov    $0x100,%edx
call   1030 <write@plt>
cmp    $0x100,%eax
je     11fa <jvcwritesectors+0xba>
lea    0xe22(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
jmp    11ff <jvcwritesectors+0xbf>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1185 <jvcwritesectors+0x45>
jmp    1212 <jvcwritesectors+0xd2>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1172 <jvcwritesectors+0x32>
jmp    1225 <jvcwritesectors+0xe5>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    115f <jvcwritesectors+0x1f>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<jvcwritesectors>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %ecx,0xc(%rsp)
mov    %edx,0x10(%rsp)
test   %edx,%edx
jle    11f3 <jvcwritesectors+0xb3>
mov    %r8d,%r15d
mov    %esi,%r13d
mov    %edi,%ebx
xor    %eax,%eax
lea    0x2ee1(%rip),%rbp
jmp    118d <jvcwritesectors+0x4d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x14(%rsp),%eax
add    $0x1,%eax
cmp    0x10(%rsp),%eax
je     11f3 <jvcwritesectors+0xb3>
mov    %eax,0x14(%rsp)
cmpl   $0x0,0xc(%rsp)
jle    1180 <jvcwritesectors+0x40>
xor    %r14d,%r14d
jmp    11ab <jvcwritesectors+0x6b>
nopl   (%rax)
add    $0x1,%r14d
cmp    0xc(%rsp),%r14d
je     1180 <jvcwritesectors+0x40>
mov    %r15d,%r12d
test   %r15d,%r15d
jle    11a0 <jvcwritesectors+0x60>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x100,%edx
call   1040 <read@plt>
test   %rax,%rax
js     1202 <jvcwritesectors+0xc2>
mov    %r13d,%edi
mov    %rbp,%rsi
mov    $0x100,%edx
call   1030 <write@plt>
cmp    $0x100,%eax
jne    120b <jvcwritesectors+0xcb>
add    $0xffffffff,%r12d
jne    11c0 <jvcwritesectors+0x80>
jmp    11a0 <jvcwritesectors+0x60>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdf7(%rip),%rdi
jmp    1212 <jvcwritesectors+0xd2>
lea    0xdfb(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@jvcwritesectors.buf = internal global [256 x i8] zeroinitializer
@.str = [13 x i8] c"read sectors\00"
@.str.1 = [11 x i8] c"write jvc3\00"
define void @jvcwritesectors(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
store i32 0, i32* %11
br label %14
14: ; preds = %51, %5
%15 = load i32, i32* %11
%16 = load i32, i32* %8
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %54
18: ; preds = %14
store i32 0, i32* %12
br label %19
19: ; preds = %47, %18
%20 = load i32, i32* %12
%21 = load i32, i32* %9
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %50
23: ; preds = %19
store i32 1, i32* %13
br label %24
24: ; preds = %43, %23
%25 = load i32, i32* %13
%26 = load i32, i32* %10
%27 = icmp sle i32 %25, %26
br i1 %27, label %28, label %46
28: ; preds = %24
%29 = load i32, i32* %6
%30 = call i64 @read(i32 %29, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @jvcwritesectors.buf, i64 0, i64 0), i32 256)
%31 = icmp slt i64 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %28
%33 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%34 = call i32 @exit(i32 1)
unreachable
35: ; preds = %28
%36 = load i32, i32* %7
%37 = call i32 @write(i32 %36, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @jvcwritesectors.buf, i64 0, i64 0), i32 256)
%38 = icmp ne i32 %37, 256
br i1 %38, label %39, label %42
39: ; preds = %35
%40 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%41 = call i32 @exit(i32 1)
unreachable
42: ; preds = %35
br label %43
43: ; preds = %42
%44 = load i32, i32* %13
%45 = add nsw i32 %44, 1
store i32 %45, i32* %13
br label %24
46: ; preds = %24
br label %47
47: ; preds = %46
%48 = load i32, i32* %12
%49 = add nsw i32 %48, 1
store i32 %49, i32* %12
br label %19
50: ; preds = %19
br label %51
51: ; preds = %50
%52 = load i32, i32* %11
%53 = add nsw i32 %52, 1
store i32 %53, i32* %11
br label %14
54: ; preds = %14
ret void
}

LLVM IR (-O2):
@jvcwritesectors.buf = internal global [256 x i8] zeroinitializer
@.str = [13 x i8] c"read sectors\00"
@.str.1 = [11 x i8] c"write jvc3\00"
define void @jvcwritesectors(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %36
7: ; preds = %5
%8 = icmp sgt i32 %3, 0
%9 = icmp slt i32 %4, 1
br label %10
10: ; preds = %7, %33
%11 = phi i32 [ 0, %7 ], [ %34, %33 ]
br i1 %8, label %12, label %33
12: ; preds = %10, %30
%13 = phi i32 [ %31, %30 ], [ 0, %10 ]
br i1 %9, label %30, label %17
14: ; preds = %24
%15 = add nuw i32 %18, 1
%16 = icmp eq i32 %18, %4
br i1 %16, label %30, label %17
17: ; preds = %12, %14
%18 = phi i32 [ %15, %14 ], [ 1, %12 ]
%19 = tail call i64 @read(i32 %0, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @jvcwritesectors.buf, i64 0, i64 0), i32 256)
%20 = icmp slt i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %17
%22 = tail call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%23 = tail call i32 @exit(i32 1)
unreachable
24: ; preds = %17
%25 = tail call i32 @write(i32 %1, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @jvcwritesectors.buf, i64 0, i64 0), i32 256)
%26 = icmp eq i32 %25, 256
br i1 %26, label %14, label %27
27: ; preds = %24
%28 = tail call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%29 = tail call i32 @exit(i32 1)
unreachable
30: ; preds = %14, %12
%31 = add nuw nsw i32 %13, 1
%32 = icmp eq i32 %31, %3
br i1 %32, label %33, label %12
33: ; preds = %30, %10
%34 = add nuw nsw i32 %11, 1
%35 = icmp eq i32 %34, %2
br i1 %35, label %36, label %10
36: ; preds = %33, %5
ret void
}