#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  int nid;
  char *comment;
};
typedef int /*<<< orphan*/ FILE;
typedef TYPE_1__ EC_builtin_curve;

/* Variables and functions */
char *OBJ_nid2sn(int);
scalar_t__ fprintf(int /*<<< orphan*/ *, char *, ...);
bool write_curve(void *misc, EC_builtin_curve *curve, int digest,
                 const char *oid, const char *m, const char *n) {
  FILE *file = misc;
  if (fprintf(file, "    { %d, /* %s (%s): %s */\n", curve->nid,
              OBJ_nid2sn(curve->nid), oid, curve->comment) < 0)
    return false;
  if (fprintf(file, "      \"%s\",\n", m) < 0)
    return false;
  if (fprintf(file, "      \"%s\" },\n\n", n) < 0)
    return false;
  return true;
}


x86 assembly (clang, -O0):
<write_curve>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
call   1030 <OBJ_nid2sn@plt>
mov    -0x50(%rbp),%rdi
mov    -0x44(%rbp),%edx
mov    %rax,%rcx
mov    -0x28(%rbp),%r8
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%r9
lea    0xe80(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
cmp    $0x0,%rax
jge    119d <write_curve+0x7d>
movl   $0x0,-0x4(%rbp)
jmp    11fc <write_curve+0xdc>
mov    -0x40(%rbp),%rdi
mov    -0x30(%rbp),%rdx
lea    0xe71(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
cmp    $0x0,%rax
jge    11c9 <write_curve+0xa9>
movl   $0x0,-0x4(%rbp)
jmp    11fc <write_curve+0xdc>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rdx
lea    0xe52(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
cmp    $0x0,%rax
jge    11f5 <write_curve+0xd5>
movl   $0x0,-0x4(%rbp)
jmp    11fc <write_curve+0xdc>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_curve>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9,%r14
mov    %r8,%r12
mov    %rcx,%r13
mov    %rsi,%rbx
mov    %rdi,%r15
mov    (%rsi),%ebp
mov    %ebp,%edi
call   1030 <OBJ_nid2sn@plt>
mov    0x8(%rbx),%r9
lea    0xeb2(%rip),%rsi
xor    %ebx,%ebx
mov    %r15,%rdi
mov    %ebp,%edx
mov    %rax,%rcx
mov    %r13,%r8
xor    %eax,%eax
call   1040 <fprintf@plt>
test   %rax,%rax
js     11a0 <write_curve+0x80>
lea    0xeaf(%rip),%rsi
xor    %ebx,%ebx
mov    %r15,%rdi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
test   %rax,%rax
js     11a0 <write_curve+0x80>
lea    0xea1(%rip),%rsi
mov    %r15,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %rax,%rbx
shr    $0x3f,%rbx
xor    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i8* }
@.str = [29 x i8] c" { %d, /* %s (%s): %s */\0A\00"
@.str.1 = [13 x i8] c" \22%s\22,\0A\00"
@.str.2 = [16 x i8] c" \22%s\22 },\0A\0A\00"
define i32 @write_curve(i8* %0, %struct.TYPE_3__* %1, i32 %2, i8* %3, i8* %4, i8* %5) {
%7 = alloca i32
%8 = alloca i8*
%9 = alloca %struct.TYPE_3__*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i32*
store i8* %0, i8** %8
store %struct.TYPE_3__* %1, %struct.TYPE_3__** %9
store i32 %2, i32* %10
store i8* %3, i8** %11
store i8* %4, i8** %12
store i8* %5, i8** %13
%15 = load i8*, i8** %8
%16 = bitcast i8* %15 to i32*
store i32* %16, i32** %14
%17 = load i32*, i32** %14
%18 = load %struct.TYPE_3__*, %struct.TYPE_3__** %9
%19 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %18, i32 0, i32 0
%20 = load i32, i32* %19
%21 = load %struct.TYPE_3__*, %struct.TYPE_3__** %9
%22 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %21, i32 0, i32 0
%23 = load i32, i32* %22
%24 = call i8* @OBJ_nid2sn(i32 %23)
%25 = load i8*, i8** %11
%26 = load %struct.TYPE_3__*, %struct.TYPE_3__** %9
%27 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %26, i32 0, i32 1
%28 = load i8*, i8** %27
%29 = call i64 (i32*, i8*, ...) @fprintf(i32* %17, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %20, i8* %24, i8* %25, i8* %28)
%30 = icmp slt i64 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %6
store i32 0, i32* %7
br label %45
32: ; preds = %6
%33 = load i32*, i32** %14
%34 = load i8*, i8** %12
%35 = call i64 (i32*, i8*, ...) @fprintf(i32* %33, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %34)
%36 = icmp slt i64 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %32
store i32 0, i32* %7
br label %45
38: ; preds = %32
%39 = load i32*, i32** %14
%40 = load i8*, i8** %13
%41 = call i64 (i32*, i8*, ...) @fprintf(i32* %39, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %40)
%42 = icmp slt i64 %41, 0
br i1 %42, label %43, label %44
43: ; preds = %38
store i32 0, i32* %7
br label %45
44: ; preds = %38
store i32 1, i32* %7
br label %45
45: ; preds = %44, %43, %37, %31
%46 = load i32, i32* %7
ret i32 %46
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i8* }
@.str = [29 x i8] c" { %d, /* %s (%s): %s */\0A\00"
@.str.1 = [13 x i8] c" \22%s\22,\0A\00"
@.str.2 = [16 x i8] c" \22%s\22 },\0A\0A\00"
define i32 @write_curve(i8* nocapture %0, %struct.TYPE_3__* nocapture %1, i32 %2, i8* %3, i8* %4, i8* %5) {
%7 = bitcast i8* %0 to i32*
%8 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i64 0, i32 0
%9 = load i32, i32* %8
%10 = tail call i8* @OBJ_nid2sn(i32 %9)
%11 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i64 0, i32 1
%12 = load i8*, i8** %11
%13 = tail call i64 (i32*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %9, i8* %10, i8* %3, i8* %12)
%14 = icmp slt i64 %13, 0
br i1 %14, label %23, label %15
15: ; preds = %6
%16 = tail call i64 (i32*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%17 = icmp slt i64 %16, 0
br i1 %17, label %23, label %18
18: ; preds = %15
%19 = tail call i64 (i32*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%20 = lshr i64 %19, 63
%21 = trunc i64 %20 to i32
%22 = xor i32 %21, 1
br label %23
23: ; preds = %18, %15, %6
%24 = phi i32 [ 0, %6 ], [ 0, %15 ], [ %22, %18 ]
ret i32 %24
}