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

/* Variables and functions */
int /*<<< orphan*/ ENGINE_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *ENGINE_get_first();
char *ENGINE_get_id(int /*<<< orphan*/ *);
char *ENGINE_get_name(int /*<<< orphan*/ *);
int /*<<< orphan*/ *ENGINE_get_next(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
void display_engine_list() {
  ENGINE *h;
  int loop;
  h = ENGINE_get_first();
  loop = 0;
  printf("listing available engine types\n");
  while (h) {
    printf("engine %i, id = \"%s\", name = \"%s\"\n", loop++, ENGINE_get_id(h),
           ENGINE_get_name(h));
    h = ENGINE_get_next(h);
  }
  printf("end of list\n");
  ENGINE_free(h);
}


x86 assembly (clang, -O0):
<display_engine_list>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1070 <ENGINE_get_first@plt>
mov    %rax,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpq   $0x0,-0x8(%rbp)
je     11df <display_engine_list+0x7f>
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1080 <ENGINE_get_id@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <ENGINE_get_name@plt>
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    %rax,%rcx
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1060 <ENGINE_get_next@plt>
mov    %rax,-0x8(%rbp)
jmp    1188 <display_engine_list+0x28>
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <ENGINE_free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display_engine_list>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %eax,%eax
call   1080 <ENGINE_get_first@plt>
mov    %rax,%r15
lea    0xe9a(%rip),%rdi
call   1040 <puts@plt>
test   %r15,%r15
je     11da <display_engine_list+0x6a>
lea    0xe66(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax)
lea    0x1(%rbx),%ebp
mov    %r15,%rdi
call   1090 <ENGINE_get_id@plt>
mov    %rax,%r12
mov    %r15,%rdi
call   1050 <ENGINE_get_name@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %r12,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%rdi
call   1070 <ENGINE_get_next@plt>
mov    %rax,%r15
mov    %ebp,%ebx
test   %rax,%rax
jne    11a0 <display_engine_list+0x30>
lea    0xe61(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <ENGINE_free@plt>

LLVM IR (-O0):
@.str = [32 x i8] c"listing available engine types\0A\00"
@.str.1 = [35 x i8] c"engine %i, id = \22%s\22, name = \22%s\22\0A\00"
@.str.2 = [13 x i8] c"end of list\0A\00"
define void @display_engine_list() {
%1 = alloca i32*
%2 = alloca i32
%3 = call i32* (...) @ENGINE_get_first()
store i32* %3, i32** %1
store i32 0, i32* %2
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %8, %0
%6 = load i32*, i32** %1
%7 = icmp ne i32* %6, null
br i1 %7, label %8, label %18
8: ; preds = %5
%9 = load i32, i32* %2
%10 = add nsw i32 %9, 1
store i32 %10, i32* %2
%11 = load i32*, i32** %1
%12 = call i8* @ENGINE_get_id(i32* %11)
%13 = load i32*, i32** %1
%14 = call i8* @ENGINE_get_name(i32* %13)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 %9, i8* %12, i8* %14)
%16 = load i32*, i32** %1
%17 = call i32* @ENGINE_get_next(i32* %16)
store i32* %17, i32** %1
br label %5
18: ; preds = %5
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%20 = load i32*, i32** %1
%21 = call i32 @ENGINE_free(i32* %20)
ret void
}

LLVM IR (-O2):
@.str.1 = [35 x i8] c"engine %i, id = \22%s\22, name = \22%s\22\0A\00"
@str = [31 x i8] c"listing available engine types\00"
@str.3 = [12 x i8] c"end of list\00"
define void @display_engine_list() {
%1 = tail call i32* (...) @ENGINE_get_first()
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%3 = icmp eq i32* %1, null
br i1 %3, label %13, label %4
4: ; preds = %0, %4
%5 = phi i32 [ %7, %4 ], [ 0, %0 ]
%6 = phi i32* [ %11, %4 ], [ %1, %0 ]
%7 = add nuw nsw i32 %5, 1
%8 = tail call i8* @ENGINE_get_id(i32* %6)
%9 = tail call i8* @ENGINE_get_name(i32* %6)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 %5, i8* %8, i8* %9)
%11 = tail call i32* @ENGINE_get_next(i32* %6)
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %4
13: ; preds = %4, %0
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.3, i64 0, i64 0))
%15 = tail call i32 @ENGINE_free(i32* null)
ret void
}