#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 cifs_sid {
  int dummy;
};

/* Variables and functions */
int EINVAL;
int /*<<< orphan*/ print_sid(struct cifs_sid *, int);
int /*<<< orphan*/ printf(char *, ...);
int parse_sid(struct cifs_sid *psid, char *end_of_acl, char *title, int raw) {
  if (end_of_acl < (char *)psid + 8)
    return -EINVAL;
  if (title)
    printf("%s:", title);
  print_sid((struct cifs_sid *)psid, raw);
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<parse_sid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
add    $0x8,%rcx
cmp    %rcx,%rax
jae    115f <parse_sid+0x3f>
xor    %eax,%eax
mov    0x2e8b(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    119d <parse_sid+0x7d>
cmpq   $0x0,-0x20(%rbp)
je     117c <parse_sid+0x5c>
mov    -0x20(%rbp),%rsi
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1040 <print_sid@plt>
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_sid>:
push   %rbp
push   %rbx
push   %rax
lea    0x8(%rdi),%rax
cmp    %rsi,%rax
jbe    1149 <parse_sid+0x19>
mov    0x2e9d(%rip),%rcx
xor    %eax,%eax
sub    (%rcx),%eax
jmp    117a <parse_sid+0x4a>
mov    %ecx,%ebp
mov    %rdi,%rbx
test   %rdx,%rdx
je     1164 <parse_sid+0x34>
lea    0xea6(%rip),%rdi
mov    %rdx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1050 <print_sid@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.cifs_sid = type { i32 }
@EINVAL = global i32 0
@.str = [4 x i8] c"%s:\00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @parse_sid(%struct.cifs_sid* %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca %struct.cifs_sid*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
store %struct.cifs_sid* %0, %struct.cifs_sid** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i32 %3, i32* %9
%10 = load i8*, i8** %7
%11 = load %struct.cifs_sid*, %struct.cifs_sid** %6
%12 = bitcast %struct.cifs_sid* %11 to i8*
%13 = getelementptr inbounds i8, i8* %12, i64 8
%14 = icmp ult i8* %10, %13
br i1 %14, label %15, label %18
15: ; preds = %4
%16 = load i32, i32* @EINVAL
%17 = sub nsw i32 0, %16
store i32 %17, i32* %5
br label %29
18: ; preds = %4
%19 = load i8*, i8** %8
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = load i8*, i8** %8
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %22)
br label %24
24: ; preds = %21, %18
%25 = load %struct.cifs_sid*, %struct.cifs_sid** %6
%26 = load i32, i32* %9
%27 = call i32 @print_sid(%struct.cifs_sid* %25, i32 %26)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %5
br label %29
29: ; preds = %24, %15
%30 = load i32, i32* %5
ret i32 %30
}

LLVM IR (-O2):
%struct.cifs_sid = type { i32 }
@EINVAL = global i32 0
@.str = [4 x i8] c"%s:\00"
define i32 @parse_sid(%struct.cifs_sid* %0, i8* readnone %1, i8* %2, i32 %3) {
%5 = getelementptr inbounds %struct.cifs_sid, %struct.cifs_sid* %0, i64 2
%6 = bitcast %struct.cifs_sid* %5 to i8*
%7 = icmp ugt i8* %6, %1
br i1 %7, label %8, label %11
8: ; preds = %4
%9 = load i32, i32* @EINVAL
%10 = sub nsw i32 0, %9
br label %18
11: ; preds = %4
%12 = icmp eq i8* %2, null
br i1 %12, label %15, label %13
13: ; preds = %11
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %2)
br label %15
15: ; preds = %13, %11
%16 = tail call i32 @print_sid(%struct.cifs_sid* %0, i32 %3)
%17 = tail call i32 @putchar(i32 10)
br label %18
18: ; preds = %15, %8
%19 = phi i32 [ %10, %8 ], [ 0, %15 ]
ret i32 %19
}