#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 */
int describe_device(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int dev_describe_device(int id, int fd, char *dev_name, FILE *fp) {
  fprintf(fp, "\n[Device Begin]\n");
  fprintf(fp, "id = %d\n", id);
  fprintf(fp, "type = unknown\n");
  fprintf(fp, "name = %s\n", dev_name);
  int ret = describe_device(fd, fp);
  fprintf(fp, "\n[Device End]\n");
  return ret;
}


x86 assembly (clang, -O0):
<dev_describe_device>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xebf(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xebb(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xeb2(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xeac(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1030 <describe_device@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe96(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dev_describe_device>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rcx,%rbx
mov    %rdx,%r15
mov    %esi,%r14d
mov    %edi,%ebp
lea    0xeb7(%rip),%rdi
mov    $0x10,%esi
mov    $0x1,%edx
call   1050 <fwrite@plt>
lea    0xeb2(%rip),%rsi
mov    %rbx,%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
lea    0xea8(%rip),%rdi
mov    $0xf,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1050 <fwrite@plt>
lea    0xe9f(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
call   1030 <describe_device@plt>
mov    %eax,%ebp
lea    0xe89(%rip),%rdi
mov    $0xe,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1050 <fwrite@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"\0A[Device Begin]\0A\00"
@.str.1 = [9 x i8] c"id = %d\0A\00"
@.str.2 = [16 x i8] c"type = unknown\0A\00"
@.str.3 = [11 x i8] c"name = %s\0A\00"
@.str.4 = [15 x i8] c"\0A[Device End]\0A\00"
define i32 @dev_describe_device(i32 %0, i32 %1, i8* %2, i32* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i32* %3, i32** %8
%10 = load i32*, i32** %8
%11 = call i32 (i32*, i8*, ...) @fprintf(i32* %10, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%12 = load i32*, i32** %8
%13 = load i32, i32* %5
%14 = call i32 (i32*, i8*, ...) @fprintf(i32* %12, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = load i32*, i32** %8
%16 = call i32 (i32*, i8*, ...) @fprintf(i32* %15, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%17 = load i32*, i32** %8
%18 = load i8*, i8** %7
%19 = call i32 (i32*, i8*, ...) @fprintf(i32* %17, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %18)
%20 = load i32, i32* %6
%21 = load i32*, i32** %8
%22 = call i32 @describe_device(i32 %20, i32* %21)
store i32 %22, i32* %9
%23 = load i32*, i32** %8
%24 = call i32 (i32*, i8*, ...) @fprintf(i32* %23, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%25 = load i32, i32* %9
ret i32 %25
}

LLVM IR (-O2):
@.str = [17 x i8] c"\0A[Device Begin]\0A\00"
@.str.1 = [9 x i8] c"id = %d\0A\00"
@.str.2 = [16 x i8] c"type = unknown\0A\00"
@.str.3 = [11 x i8] c"name = %s\0A\00"
@.str.4 = [15 x i8] c"\0A[Device End]\0A\00"
define i32 @dev_describe_device(i32 %0, i32 %1, i8* %2, i32* %3) {
%5 = tail call i64 @fwrite(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 16, i64 1, i32* %3)
%6 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %3, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %0)
%7 = tail call i64 @fwrite(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i64 15, i64 1, i32* %3)
%8 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %3, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %2)
%9 = tail call i32 @describe_device(i32 %1, i32* %3)
%10 = tail call i64 @fwrite(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i64 14, i64 1, i32* %3)
ret i32 %9
}