#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 */
struct ar_hdr {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_CUR;
int _ar_error(char const *, int);
scalar_t__ _ar_get_size(struct ar_hdr *, size_t *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char const *,
                           char *);
scalar_t__ fseek(int /*<<< orphan*/ *, size_t, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int _do_seek_next(char const *archive, FILE *fp, struct ar_hdr *hdr) {
  size_t size;
  if (_ar_get_size(hdr, &size) != 0) {
    fprintf(stderr, "%s%s%s",
            "ar"
            ": ",
            archive, ": Invalid archive\n");
    return 1;
  }
  if (size & 0x1)
    size++;
  if (fseek(fp, size, SEEK_CUR) != 0)
    return _ar_error(archive, 1);
  return 0;
}


x86 assembly (clang, -O0):
<_do_seek_next>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1030 <_ar_get_size@plt>
cmp    $0x0,%rax
je     119e <_do_seek_next+0x5e>
mov    0x2e66(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rcx
lea    0xe81(%rip),%rsi
lea    0xe81(%rip),%rdx
lea    0xe7f(%rip),%r8
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11f9 <_do_seek_next+0xb9>
mov    -0x28(%rbp),%rax
and    $0x1,%rax
cmp    $0x0,%rax
je     11bc <_do_seek_next+0x7c>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    0x2e1d(%rip),%rax
mov    (%rax),%edx
call   1050 <fseek@plt>
cmp    $0x0,%rax
je     11f2 <_do_seek_next+0xb2>
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1060 <_ar_error@plt>
mov    %eax,-0x4(%rbp)
jmp    11f9 <_do_seek_next+0xb9>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_do_seek_next>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsp,%rsi
mov    %rdx,%rdi
call   1030 <_ar_get_size@plt>
test   %rax,%rax
je     1187 <_do_seek_next+0x47>
mov    0x2e77(%rip),%rax
mov    (%rax),%edi
lea    0xe96(%rip),%rsi
lea    0xe96(%rip),%rdx
lea    0xe94(%rip),%r8
mov    %r14,%rcx
call   1040 <fprintf@plt>
mov    $0x1,%eax
jmp    11c0 <_do_seek_next+0x80>
mov    (%rsp),%rsi
test   $0x1,%sil
je     1199 <_do_seek_next+0x59>
add    $0x1,%rsi
mov    %rsi,(%rsp)
mov    0x2e48(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
call   1050 <fseek@plt>
test   %rax,%rax
je     11be <_do_seek_next+0x7e>
mov    %r14,%rdi
mov    $0x1,%esi
call   1060 <_ar_error@plt>
jmp    11c0 <_do_seek_next+0x80>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.ar_hdr = type { i32 }
@stderr = global i32 0
@.str = [7 x i8] c"%s%s%s\00"
@.str.1 = [5 x i8] c"ar: \00"
@.str.2 = [19 x i8] c": Invalid archive\0A\00"
@SEEK_CUR = global i32 0
define i32 @_do_seek_next(i8* %0, i32* %1, %struct.ar_hdr* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca %struct.ar_hdr*
%8 = alloca i64
store i8* %0, i8** %5
store i32* %1, i32** %6
store %struct.ar_hdr* %2, %struct.ar_hdr** %7
%9 = load %struct.ar_hdr*, %struct.ar_hdr** %7
%10 = call i64 @_ar_get_size(%struct.ar_hdr* %9, i64* %8)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %3
%13 = load i32, i32* @stderr
%14 = load i8*, i8** %5
%15 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %14, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %4
br label %33
16: ; preds = %3
%17 = load i64, i64* %8
%18 = and i64 %17, 1
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %16
%21 = load i64, i64* %8
%22 = add i64 %21, 1
store i64 %22, i64* %8
br label %23
23: ; preds = %20, %16
%24 = load i32*, i32** %6
%25 = load i64, i64* %8
%26 = load i32, i32* @SEEK_CUR
%27 = call i64 @fseek(i32* %24, i64 %25, i32 %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %23
%30 = load i8*, i8** %5
%31 = call i32 @_ar_error(i8* %30, i32 1)
store i32 %31, i32* %4
br label %33
32: ; preds = %23
store i32 0, i32* %4
br label %33
33: ; preds = %32, %29, %12
%34 = load i32, i32* %4
ret i32 %34
}

LLVM IR (-O2):
%struct.ar_hdr = type { i32 }
@stderr = global i32 0
@.str = [7 x i8] c"%s%s%s\00"
@.str.1 = [5 x i8] c"ar: \00"
@.str.2 = [19 x i8] c": Invalid archive\0A\00"
@SEEK_CUR = global i32 0
define i32 @_do_seek_next(i8* %0, i32* nocapture %1, %struct.ar_hdr* %2) {
%4 = alloca i64
%5 = bitcast i64* %4 to i8*
%6 = call i64 @_ar_get_size(%struct.ar_hdr* %2, i64* %4)
%7 = icmp eq i64 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %3
%9 = load i32, i32* @stderr
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
br label %24
11: ; preds = %3
%12 = load i64, i64* %4
%13 = and i64 %12, 1
%14 = icmp eq i64 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %11
%16 = add i64 %12, 1
store i64 %16, i64* %4
br label %17
17: ; preds = %15, %11
%18 = phi i64 [ %16, %15 ], [ %12, %11 ]
%19 = load i32, i32* @SEEK_CUR
%20 = call i64 @fseek(i32* %1, i64 %18, i32 %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %17
%23 = call i32 @_ar_error(i8* %0, i32 1)
br label %24
24: ; preds = %17, %22, %8
%25 = phi i32 [ 1, %8 ], [ %23, %22 ], [ 0, %17 ]
ret i32 %25
}