#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_expression(char const *, int /*<<< orphan*/ *);
char peek(char const **);
int /*<<< orphan*/ stderr;
const char *parse_slice_offset(const char *p, ssize_t *offset) {
  if ((p = parse_expression(p, offset))) {
    if (peek(&p) != '\0' && peek(&p) != ':') {
      fprintf(stderr, "junk '%s' after slice offset\n", p);
      p = NULL;
    }
  }
  return p;
}


x86 assembly (clang, -O0):
<parse_slice_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_expression@plt>
mov    %rax,-0x8(%rbp)
cmp    $0x0,%rax
je     11ab <parse_slice_offset+0x7b>
lea    -0x8(%rbp),%rdi
call   1030 <peek@plt>
movsbl %al,%eax
cmp    $0x0,%eax
je     11a6 <parse_slice_offset+0x76>
lea    -0x8(%rbp),%rdi
call   1030 <peek@plt>
movsbl %al,%eax
cmp    $0x3a,%eax
je     11a6 <parse_slice_offset+0x76>
mov    0x2e54(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe67(%rip),%rsi
call   1040 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    11ab <parse_slice_offset+0x7b>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_slice_offset>:
push   %rax
call   1050 <parse_expression@plt>
mov    %rax,(%rsp)
test   %rax,%rax
je     1178 <parse_slice_offset+0x48>
mov    %rsp,%rdi
call   1030 <peek@plt>
test   %al,%al
je     1178 <parse_slice_offset+0x48>
mov    %rsp,%rdi
call   1030 <peek@plt>
cmp    $0x3a,%al
je     1178 <parse_slice_offset+0x48>
mov    0x2e82(%rip),%rax
mov    (%rax),%edi
mov    (%rsp),%rdx
lea    0xe95(%rip),%rsi
call   1040 <fprintf@plt>
movq   $0x0,(%rsp)
mov    (%rsp),%rax
pop    %rcx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [30 x i8] c"junk '%s' after slice offset\0A\00"
define i8* @parse_slice_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_expression(i8* %5, i32* %6)
store i8* %7, i8** %3
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %22
9: ; preds = %2
%10 = call signext i8 @peek(i8** %3)
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %21
13: ; preds = %9
%14 = call signext i8 @peek(i8** %3)
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 58
br i1 %16, label %17, label %21
17: ; preds = %13
%18 = load i32, i32* @stderr
%19 = load i8*, i8** %3
%20 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %19)
store i8* null, i8** %3
br label %21
21: ; preds = %17, %13, %9
br label %22
22: ; preds = %21, %2
%23 = load i8*, i8** %3
ret i8* %23
}

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