#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 prom_args TYPE_1__;

/* Type definitions */
struct prom_args {
  char *service;
  int nargs;
  int nret;
  void *ihandle;
  void *addr;
  int len;
  int actual;
};

/* Variables and functions */
int /*<<< orphan*/ prom(TYPE_1__ *);
int write(void *handle, void *ptr, int nb) {
  struct prom_args {
    char *service;
    int nargs;
    int nret;
    void *ihandle;
    void *addr;
    int len;
    int actual;
  } args;
  args.service = "write";
  args.nargs = 3;
  args.nret = 1;
  args.ihandle = handle;
  args.addr = ptr;
  args.len = nb;
  args.actual = -1;
  prom(&args);
  return args.actual;
}


x86 assembly (clang, -O0):
<write>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
lea    0xed6(%rip),%rax
mov    %rax,-0x40(%rbp)
movl   $0x3,-0x38(%rbp)
movl   $0x1,-0x34(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
movl   $0xffffffff,-0x1c(%rbp)
lea    -0x40(%rbp),%rdi
call   1030 <prom@plt>
mov    -0x1c(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write>:
sub    $0x28,%rsp
lea    0xee5(%rip),%rax
mov    %rax,(%rsp)
movabs $0x100000003,%rax
mov    %rax,0x8(%rsp)
mov    %rdi,0x10(%rsp)
mov    %rsi,0x18(%rsp)
mov    %edx,0x20(%rsp)
movl   $0xffffffff,0x24(%rsp)
ff
mov    %rsp,%rdi
call   1030 <prom@plt>
mov    0x24(%rsp),%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
%struct.prom_args = type { i8*, i32, i32, i8*, i8*, i32, i32 }
%struct.prom_args.0 = type { i8*, i32, i32, i8*, i8*, i32, i32 }
@.str = [6 x i8] c"write\00"
define i32 @write(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca %struct.prom_args
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%8 = getelementptr inbounds %struct.prom_args, %struct.prom_args* %7, i32 0, i32 0
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %8
%9 = getelementptr inbounds %struct.prom_args, %struct.prom_args* %7, i32 0, i32 1
store i32 3, i32* %9
%10 = getelementptr inbounds %struct.prom_args, %struct.prom_args* %7, i32 0, i32 2
store i32 1, i32* %10
%11 = load i8*, i8** %4
%12 = getelementptr inbounds %struct.prom_args, %struct.prom_args* %7, i32 0, i32 3
store i8* %11, i8** %12
%13 = load i8*, i8** %5
%14 = getelementptr inbounds %struct.prom_args, %struct.prom_args* %7, i32 0, i32 4
store i8* %13, i8** %14
%15 = load i32, i32* %6
%16 = getelementptr inbounds %struct.prom_args, %struct.prom_args* %7, i32 0, i32 5
store i32 %15, i32* %16
%17 = getelementptr inbounds %struct.prom_args, %struct.prom_args* %7, i32 0, i32 6
store i32 -1, i32* %17
%18 = bitcast %struct.prom_args* %7 to %struct.prom_args.0*
%19 = call i32 @prom(%struct.prom_args.0* %18)
%20 = getelementptr inbounds %struct.prom_args, %struct.prom_args* %7, i32 0, i32 6
%21 = load i32, i32* %20
ret i32 %21
}

LLVM IR (-O2):
%struct.prom_args = type { i8*, i32, i32, i8*, i8*, i32, i32 }
%struct.prom_args.0 = type { i8*, i32, i32, i8*, i8*, i32, i32 }
@.str = [6 x i8] c"write\00"
define i32 @write(i8* %0, i8* %1, i32 %2) {
%4 = alloca %struct.prom_args
%5 = bitcast %struct.prom_args* %4 to i8*
%6 = getelementptr inbounds %struct.prom_args, %struct.prom_args* %4, i64 0, i32 0
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %6
%7 = getelementptr inbounds %struct.prom_args, %struct.prom_args* %4, i64 0, i32 1
store i32 3, i32* %7
%8 = getelementptr inbounds %struct.prom_args, %struct.prom_args* %4, i64 0, i32 2
store i32 1, i32* %8
%9 = getelementptr inbounds %struct.prom_args, %struct.prom_args* %4, i64 0, i32 3
store i8* %0, i8** %9
%10 = getelementptr inbounds %struct.prom_args, %struct.prom_args* %4, i64 0, i32 4
store i8* %1, i8** %10
%11 = getelementptr inbounds %struct.prom_args, %struct.prom_args* %4, i64 0, i32 5
store i32 %2, i32* %11
%12 = getelementptr inbounds %struct.prom_args, %struct.prom_args* %4, i64 0, i32 6
store i32 -1, i32* %12
%13 = bitcast %struct.prom_args* %4 to %struct.prom_args.0*
%14 = call i32 @prom(%struct.prom_args.0* %13)
%15 = load i32, i32* %12
ret i32 %15
}