#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 *);
int /*<<< orphan*/ unlink(char *);
int write(int, char *, int);
int check_byte_alignment(int in_fd, int total_written, char *file_name) {
  if (total_written % 2) {
    ;
    if (write(in_fd, "\n", 1) == -1) {
      perror("Error writing to file");
      unlink(file_name);
      exit(-1);
    }
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<check_byte_alignment>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     11ae <check_byte_alignment+0x6e>
mov    -0x8(%rbp),%edi
lea    0xe90(%rip),%rsi
mov    $0x1,%edx
call   1040 <write@plt>
cmp    $0xffffffff,%eax
jne    11a2 <check_byte_alignment+0x62>
lea    0xe78(%rip),%rdi
call   1050 <perror@plt>
mov    -0x18(%rbp),%rdi
call   1030 <unlink@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
movl   $0x1,-0x4(%rbp)
jmp    11b5 <check_byte_alignment+0x75>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_byte_alignment>:
push   %rbp
push   %rbx
push   %rax
xor    %ebp,%ebp
test   $0x1,%sil
je     1169 <check_byte_alignment+0x29>
mov    %rdx,%rbx
lea    0xeab(%rip),%rsi
mov    $0x1,%ebp
mov    $0x1,%edx
call   1040 <write@plt>
cmp    $0xffffffff,%eax
je     1172 <check_byte_alignment+0x32>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe89(%rip),%rdi
call   1050 <perror@plt>
mov    %rbx,%rdi
call   1030 <unlink@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [22 x i8] c"Error writing to file\00"
define i32 @check_byte_alignment(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
store i32 %0, i32* %5
store i32 %1, i32* %6
store i8* %2, i8** %7
%8 = load i32, i32* %6
%9 = srem i32 %8, 2
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %21
11: ; preds = %3
%12 = load i32, i32* %5
%13 = call i32 @write(i32 %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %20
15: ; preds = %11
%16 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%17 = load i8*, i8** %7
%18 = call i32 @unlink(i8* %17)
%19 = call i32 @exit(i32 -1)
unreachable
20: ; preds = %11
store i32 1, i32* %4
br label %22
21: ; preds = %3
store i32 0, i32* %4
br label %22
22: ; preds = %21, %20
%23 = load i32, i32* %4
ret i32 %23
}

LLVM IR (-O2):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [22 x i8] c"Error writing to file\00"
define i32 @check_byte_alignment(i32 %0, i32 %1, i8* nocapture %2) {
%4 = and i32 %1, 1
%5 = icmp eq i32 %4, 0
br i1 %5, label %13, label %6
6: ; preds = %3
%7 = tail call i32 @write(i32 %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %13
9: ; preds = %6
%10 = tail call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%11 = tail call i32 @unlink(i8* %2)
%12 = tail call i32 @exit(i32 -1)
unreachable
13: ; preds = %3, %6
%14 = phi i32 [ 1, %6 ], [ 0, %3 ]
ret i32 %14
}