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

/* Variables and functions */
char *check_array(char const *);
char *check_funcptr(char const *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ fwrite(char const *, int, int, int /*<<< orphan*/ *);
void print_formalparm(FILE *stream, const char *argtype, int parmno) {
  const char *part2;
  int len;
  if ((part2 = check_funcptr(argtype)) != NULL ||
      (part2 = check_array(argtype)) != NULL) {
    len = part2 - argtype;
    (void)fwrite(argtype, 1, len, stream);
    fprintf(stream, "parm%d%s", parmno, part2);
  } else
    fprintf(stream, "%s parm%d", argtype, parmno);
}


x86 assembly (clang, -O0):
<print_formalparm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <check_funcptr@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1181 <print_formalparm+0x41>
mov    -0x10(%rbp),%rdi
call   1030 <check_array@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     11c2 <print_formalparm+0x82>
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%edx
mov    -0x8(%rbp),%rcx
mov    $0x1,%esi
call   1060 <fwrite@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%rcx
lea    0xe4a(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    11db <print_formalparm+0x9b>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
lea    0xe35(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_formalparm>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%rbp
mov    %rdi,%r15
mov    %rsi,%rdi
call   1050 <check_funcptr@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1170 <print_formalparm+0x30>
mov    %rbp,%rdi
call   1030 <check_array@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11a5 <print_formalparm+0x65>
mov    %ebx,%edx
sub    %ebp,%edx
mov    %rbp,%rdi
mov    $0x1,%esi
mov    %r15,%rcx
call   1060 <fwrite@plt>
lea    0xe75(%rip),%rsi
mov    %r15,%rdi
mov    %r14d,%edx
mov    %rbx,%rcx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fprintf@plt>
lea    0xe5d(%rip),%rsi
mov    %r15,%rdi
mov    %rbp,%rdx
mov    %r14d,%ecx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fprintf@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"parm%d%s\00"
@.str.1 = [10 x i8] c"%s parm%d\00"
define void @print_formalparm(i32* %0, i8* %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%9 = load i8*, i8** %5
%10 = call i8* @check_funcptr(i8* %9)
store i8* %10, i8** %7
%11 = icmp ne i8* %10, null
br i1 %11, label %16, label %12
12: ; preds = %3
%13 = load i8*, i8** %5
%14 = call i8* @check_array(i8* %13)
store i8* %14, i8** %7
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %31
16: ; preds = %12, %3
%17 = load i8*, i8** %7
%18 = load i8*, i8** %5
%19 = ptrtoint i8* %17 to i64
%20 = ptrtoint i8* %18 to i64
%21 = sub i64 %19, %20
%22 = trunc i64 %21 to i32
store i32 %22, i32* %8
%23 = load i8*, i8** %5
%24 = load i32, i32* %8
%25 = load i32*, i32** %4
%26 = call i32 @fwrite(i8* %23, i32 1, i32 %24, i32* %25)
%27 = load i32*, i32** %4
%28 = load i32, i32* %6
%29 = load i8*, i8** %7
%30 = call i32 (i32*, i8*, ...) @fprintf(i32* %27, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %28, i8* %29)
br label %36
31: ; preds = %12
%32 = load i32*, i32** %4
%33 = load i8*, i8** %5
%34 = load i32, i32* %6
%35 = call i32 (i32*, i8*, ...) @fprintf(i32* %32, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %33, i32 %34)
br label %36
36: ; preds = %31, %16
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"parm%d%s\00"
@.str.1 = [10 x i8] c"%s parm%d\00"
define void @print_formalparm(i32* nocapture %0, i8* %1, i32 %2) {
%4 = tail call i8* @check_funcptr(i8* %1)
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %9
6: ; preds = %3
%7 = tail call i8* @check_array(i8* %1)
%8 = icmp eq i8* %7, null
br i1 %8, label %17, label %9
9: ; preds = %6, %3
%10 = phi i8* [ %4, %3 ], [ %7, %6 ]
%11 = ptrtoint i8* %10 to i64
%12 = ptrtoint i8* %1 to i64
%13 = sub i64 %11, %12
%14 = trunc i64 %13 to i32
%15 = tail call i32 @fwrite(i8* %1, i32 1, i32 %14, i32* %0)
%16 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %2, i8* %10)
br label %19
17: ; preds = %6
%18 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %1, i32 %2)
br label %19
19: ; preds = %17, %9
ret void
}