#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 */
char *gettext(char *);
char *realloc(char *, int);
int /*<<< orphan*/ sprintf(char *, char *, char *, ...);
int strlen(char *);
char *ipr_list_opts(char *body, char *key, char *list_str) {
  int start_len = 0;
  char *string_buf = gettext("Select one of the following");
  if (!body) {
    body = realloc(body, strlen(string_buf) + 8);
    sprintf(body, "\n%s:\n\n", string_buf);
  }
  start_len = strlen(body);
  body =
      realloc(body, start_len + strlen(key) + strlen(gettext(list_str)) + 16);
  sprintf(body + start_len, "    %s. %s\n", key, gettext(list_str));
  return body;
}


x86 assembly (clang, -O0):
<ipr_list_opts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xe9e(%rip),%rdi
call   1040 <gettext@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    11af <ipr_list_opts+0x6f>
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    %eax,%esi
add    $0x8,%esi
call   1050 <realloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xe74(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x50(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x4c(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <gettext@plt>
mov    %rax,%rdi
call   1030 <strlen@plt>
mov    -0x4c(%rbp),%esi
mov    -0x48(%rbp),%rdi
add    %eax,%esi
add    $0x10,%esi
call   1050 <realloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <gettext@plt>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rdx
mov    %rax,%rcx
lea    0xdef(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ipr_list_opts>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xea8(%rip),%rdi
call   1040 <gettext@plt>
test   %rbx,%rbx
jne    118e <ipr_list_opts+0x4e>
mov    %rax,%r12
mov    %rax,%rdi
call   1030 <strlen@plt>
lea    0x8(%rax),%esi
xor    %edi,%edi
call   1050 <realloc@plt>
mov    %rax,%rbx
lea    0xe9b(%rip),%rsi
mov    %rax,%rdi
mov    %r12,%rdx
xor    %eax,%eax
call   1060 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%r12d
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %r15,%rdi
call   1040 <gettext@plt>
mov    %rax,%rdi
call   1030 <strlen@plt>
add    %r12d,%ebp
lea    (%rax,%rbp,1),%esi
add    $0x10,%esi
mov    %rbx,%rdi
call   1050 <realloc@plt>
mov    %rax,%rbx
movslq %r12d,%rbp
add    %rax,%rbp
mov    %r15,%rdi
call   1040 <gettext@plt>
lea    0xe47(%rip),%rsi
mov    %rbp,%rdi
mov    %r14,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1060 <sprintf@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Select one of the following\00"
@.str.1 = [7 x i8] c"\0A%s:\0A\0A\00"
@.str.2 = [12 x i8] c" %s. %s\0A\00"
define i8* @ipr_list_opts(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
store i32 0, i32* %7
%9 = call i8* @gettext(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
store i8* %9, i8** %8
%10 = load i8*, i8** %4
%11 = icmp ne i8* %10, null
br i1 %11, label %21, label %12
12: ; preds = %3
%13 = load i8*, i8** %4
%14 = load i8*, i8** %8
%15 = call i32 @strlen(i8* %14)
%16 = add nsw i32 %15, 8
%17 = call i8* @realloc(i8* %13, i32 %16)
store i8* %17, i8** %4
%18 = load i8*, i8** %4
%19 = load i8*, i8** %8
%20 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %18, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %19)
br label %21
21: ; preds = %12, %3
%22 = load i8*, i8** %4
%23 = call i32 @strlen(i8* %22)
store i32 %23, i32* %7
%24 = load i8*, i8** %4
%25 = load i32, i32* %7
%26 = load i8*, i8** %5
%27 = call i32 @strlen(i8* %26)
%28 = add nsw i32 %25, %27
%29 = load i8*, i8** %6
%30 = call i8* @gettext(i8* %29)
%31 = call i32 @strlen(i8* %30)
%32 = add nsw i32 %28, %31
%33 = add nsw i32 %32, 16
%34 = call i8* @realloc(i8* %24, i32 %33)
store i8* %34, i8** %4
%35 = load i8*, i8** %4
%36 = load i32, i32* %7
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
%39 = load i8*, i8** %5
%40 = load i8*, i8** %6
%41 = call i8* @gettext(i8* %40)
%42 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %38, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %39, i8* %41)
%43 = load i8*, i8** %4
ret i8* %43
}

LLVM IR (-O2):
@.str = [28 x i8] c"Select one of the following\00"
@.str.1 = [7 x i8] c"\0A%s:\0A\0A\00"
@.str.2 = [12 x i8] c" %s. %s\0A\00"
define i8* @ipr_list_opts(i8* %0, i8* %1, i8* %2) {
%4 = tail call i8* @gettext(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i8* %0, null
br i1 %5, label %6, label %11
6: ; preds = %3
%7 = tail call i32 @strlen(i8* %4)
%8 = add nsw i32 %7, 8
%9 = tail call i8* @realloc(i8* null, i32 %8)
%10 = tail call i32 (i8*, i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %9, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %4)
br label %11
11: ; preds = %6, %3
%12 = phi i8* [ %0, %3 ], [ %9, %6 ]
%13 = tail call i32 @strlen(i8* %12)
%14 = tail call i32 @strlen(i8* %1)
%15 = tail call i8* @gettext(i8* %2)
%16 = tail call i32 @strlen(i8* %15)
%17 = add i32 %13, 16
%18 = add i32 %17, %14
%19 = add i32 %18, %16
%20 = tail call i8* @realloc(i8* %12, i32 %19)
%21 = sext i32 %13 to i64
%22 = getelementptr inbounds i8, i8* %20, i64 %21
%23 = tail call i8* @gettext(i8* %2)
%24 = tail call i32 (i8*, i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %22, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %1, i8* %23)
ret i8* %20
}