#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 act_keyctl_request2(int, char **);
int /*<<< orphan*/ format();
char *grab_stdin(size_t *);
int act_keyctl_prequest2(int argc, char *argv[]) {
  char *args[6];
  size_t datalen;
  if (argc != 3 && argc != 4)
    format();
  args[0] = argv[0];
  args[1] = argv[1];
  args[2] = argv[2];
  args[3] = grab_stdin(&datalen);
  args[4] = argv[3];
  args[5] = NULL;
  return act_keyctl_request2(argc + 1, args);
}


x86 assembly (clang, -O0):
<act_keyctl_prequest2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x4(%rbp)
je     115a <act_keyctl_prequest2+0x2a>
cmpl   $0x4,-0x4(%rbp)
je     115a <act_keyctl_prequest2+0x2a>
mov    $0x0,%al
call   1030 <format@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x30(%rbp)
lea    -0x48(%rbp),%rdi
call   1050 <grab_stdin@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x4(%rbp),%edi
add    $0x1,%edi
lea    -0x40(%rbp),%rsi
call   1040 <act_keyctl_request2@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<act_keyctl_prequest2>:
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%r14
mov    %edi,%ebx
lea    -0x5(%rbx),%eax
cmp    $0xfffffffd,%eax
ja     114b <act_keyctl_prequest2+0x1b>
xor    %eax,%eax
call   1030 <format@plt>
movups (%r14),%xmm0
movaps %xmm0,(%rsp)
mov    0x10(%r14),%rax
mov    %rax,0x10(%rsp)
lea    0x30(%rsp),%rdi
call   1050 <grab_stdin@plt>
mov    %rax,0x18(%rsp)
mov    0x18(%r14),%rax
mov    %rax,0x20(%rsp)
movq   $0x0,0x28(%rsp)
add    $0x1,%ebx
mov    %rsp,%rsi
mov    %ebx,%edi
call   1040 <act_keyctl_request2@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @act_keyctl_prequest2(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca [6 x i8*]
%6 = alloca i64
store i32 %0, i32* %3
store i8** %1, i8*** %4
%7 = load i32, i32* %3
%8 = icmp ne i32 %7, 3
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = load i32, i32* %3
%11 = icmp ne i32 %10, 4
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = call i32 (...) @format()
br label %14
14: ; preds = %12, %9, %2
%15 = load i8**, i8*** %4
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = getelementptr inbounds [6 x i8*], [6 x i8*]* %5, i64 0, i64 0
store i8* %17, i8** %18
%19 = load i8**, i8*** %4
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = getelementptr inbounds [6 x i8*], [6 x i8*]* %5, i64 0, i64 1
store i8* %21, i8** %22
%23 = load i8**, i8*** %4
%24 = getelementptr inbounds i8*, i8** %23, i64 2
%25 = load i8*, i8** %24
%26 = getelementptr inbounds [6 x i8*], [6 x i8*]* %5, i64 0, i64 2
store i8* %25, i8** %26
%27 = call i8* @grab_stdin(i64* %6)
%28 = getelementptr inbounds [6 x i8*], [6 x i8*]* %5, i64 0, i64 3
store i8* %27, i8** %28
%29 = load i8**, i8*** %4
%30 = getelementptr inbounds i8*, i8** %29, i64 3
%31 = load i8*, i8** %30
%32 = getelementptr inbounds [6 x i8*], [6 x i8*]* %5, i64 0, i64 4
store i8* %31, i8** %32
%33 = getelementptr inbounds [6 x i8*], [6 x i8*]* %5, i64 0, i64 5
store i8* null, i8** %33
%34 = load i32, i32* %3
%35 = add nsw i32 %34, 1
%36 = getelementptr inbounds [6 x i8*], [6 x i8*]* %5, i64 0, i64 0
%37 = call i32 @act_keyctl_request2(i32 %35, i8** %36)
ret i32 %37
}

LLVM IR (-O2):
define i32 @act_keyctl_prequest2(i32 %0, i8** nocapture %1) {
%3 = alloca [6 x i8*]
%4 = alloca i64
%5 = bitcast [6 x i8*]* %3 to i8*
%6 = bitcast i64* %4 to i8*
%7 = add i32 %0, -5
%8 = icmp ult i32 %7, -2
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = tail call i32 (...) @format()
br label %11
11: ; preds = %9, %2
%12 = getelementptr inbounds [6 x i8*], [6 x i8*]* %3, i64 0, i64 0
%13 = bitcast i8** %1 to <2 x i8*>*
%14 = load <2 x i8*>, <2 x i8*>* %13
%15 = bitcast [6 x i8*]* %3 to <2 x i8*>*
store <2 x i8*> %14, <2 x i8*>* %15
%16 = getelementptr inbounds i8*, i8** %1, i64 2
%17 = load i8*, i8** %16
%18 = getelementptr inbounds [6 x i8*], [6 x i8*]* %3, i64 0, i64 2
store i8* %17, i8** %18
%19 = call i8* @grab_stdin(i64* %4)
%20 = getelementptr inbounds [6 x i8*], [6 x i8*]* %3, i64 0, i64 3
store i8* %19, i8** %20
%21 = getelementptr inbounds i8*, i8** %1, i64 3
%22 = load i8*, i8** %21
%23 = getelementptr inbounds [6 x i8*], [6 x i8*]* %3, i64 0, i64 4
store i8* %22, i8** %23
%24 = getelementptr inbounds [6 x i8*], [6 x i8*]* %3, i64 0, i64 5
store i8* null, i8** %24
%25 = add nsw i32 %0, 1
%26 = call i32 @act_keyctl_request2(i32 %25, i8** %12)
ret i32 %26
}