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

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
char *parse_slice_offset(char const *, int /*<<< orphan*/ *);
scalar_t__ peek(char const **);
int /*<<< orphan*/ stderr;
int parse_offset(const char *p, ssize_t *offset) {
  if ((p = parse_slice_offset(p, offset))) {
    if (peek(&p)) {
      fprintf(stderr, "junk '%s' after offset\n", p);
      p = NULL;
    }
  }
  return p != NULL;
}


x86 assembly (clang, -O0):
<parse_offset>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <parse_slice_offset@plt>
mov    %rax,-0x8(%rbp)
cmp    $0x0,%rax
je     1194 <parse_offset+0x64>
lea    -0x8(%rbp),%rdi
call   1030 <peek@plt>
cmp    $0x0,%rax
je     118f <parse_offset+0x5f>
mov    0x2e6b(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe7e(%rip),%rsi
call   1040 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1194 <parse_offset+0x64>
cmpq   $0x0,-0x8(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_offset>:
push   %rbx
sub    $0x10,%rsp
call   1050 <parse_slice_offset@plt>
mov    %rax,0x8(%rsp)
xor    %ebx,%ebx
test   %rax,%rax
je     1185 <parse_offset+0x55>
lea    0x8(%rsp),%rdi
call   1030 <peek@plt>
test   %rax,%rax
je     117a <parse_offset+0x4a>
mov    0x2e84(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rsp),%rdx
lea    0xe96(%rip),%rsi
call   1040 <fprintf@plt>
movq   $0x0,0x8(%rsp)
jmp    1185 <parse_offset+0x55>
xor    %ebx,%ebx
cmpq   $0x0,0x8(%rsp)
setne  %bl
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [24 x i8] c"junk '%s' after offset\0A\00"
define i32 @parse_offset(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
store i8* %0, i8** %3
store i32* %1, i32** %4
%5 = load i8*, i8** %3
%6 = load i32*, i32** %4
%7 = call i8* @parse_slice_offset(i8* %5, i32* %6)
store i8* %7, i8** %3
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %17
9: ; preds = %2
%10 = call i64 @peek(i8** %3)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %9
%13 = load i32, i32* @stderr
%14 = load i8*, i8** %3
%15 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %14)
store i8* null, i8** %3
br label %16
16: ; preds = %12, %9
br label %17
17: ; preds = %16, %2
%18 = load i8*, i8** %3
%19 = icmp ne i8* %18, null
%20 = zext i1 %19 to i32
ret i32 %20
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [24 x i8] c"junk '%s' after offset\0A\00"
define i32 @parse_offset(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = tail call i8* @parse_slice_offset(i8* %0, i32* %1)
store i8* %4, i8** %3
%5 = icmp eq i8* %4, null
br i1 %5, label %17, label %6
6: ; preds = %2
%7 = call i64 @peek(i8** %3)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %6
%10 = load i8*, i8** %3
%11 = icmp ne i8* %10, null
%12 = zext i1 %11 to i32
br label %17
13: ; preds = %6
%14 = load i32, i32* @stderr
%15 = load i8*, i8** %3
%16 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %15)
store i8* null, i8** %3
br label %17
17: ; preds = %9, %13, %2
%18 = phi i32 [ %12, %9 ], [ 0, %13 ], [ 0, %2 ]
ret i32 %18
}