#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 */
int /*<<< orphan*/ sprintf(char *, char *);
int do_action(char *donesp, char *actsp, char *ressp) {
  int ret;
  char *mysp;
  mysp = donesp;
  donesp += sprintf(donesp, "<H1>Action Sent</H1>\n");
  donesp += sprintf(donesp, "<table border=1><tr><td><pre>\n");
  donesp += sprintf(donesp, actsp);
  donesp += sprintf(donesp, "</pre></td></tr></table>\n");
  donesp += sprintf(donesp, "<H1>Action Result</H1>\n");
  donesp += sprintf(donesp, "<pre>\n");
  donesp += sprintf(donesp, ressp);
  donesp += sprintf(donesp, "</pre></td></tr></table>\n");
  ret = donesp - mysp;
  return ret;
}


x86 assembly (clang, -O0):
<do_action>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xec9(%rip),%rsi
call   1030 <sprintf@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xebf(%rip),%rsi
call   1030 <sprintf@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <sprintf@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea1(%rip),%rsi
call   1030 <sprintf@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe9b(%rip),%rsi
call   1030 <sprintf@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe5a(%rip),%rsi
call   1030 <sprintf@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <sprintf@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe24(%rip),%rsi
call   1030 <sprintf@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_action>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rdi,%rbx
movups 0xede(%rip),%xmm0
movups %xmm0,(%rdi)
movabs $0xa3e31482f3c74,%rax
mov    %rax,0xe(%rdi)
movups 0xedc(%rip),%xmm0
movups %xmm0,0x15(%rdi)
movups 0xee0(%rip),%xmm0
movups %xmm0,0x24(%rdi)
add    $0x33,%rdi
call   1030 <sprintf@plt>
cltq
lea    (%rbx,%rax,1),%r15
add    $0x33,%r15
movups 0xedb(%rip),%xmm0
movups %xmm0,0x3c(%rbx,%rax,1)
movups 0xec6(%rip),%xmm0
movups %xmm0,0x33(%rbx,%rax,1)
movabs $0xa3e31482f3c746c,%rcx
31 3e 0a
mov    %rcx,0x5b(%rbx,%rax,1)
movups 0xec5(%rip),%xmm0
movups %xmm0,0x4c(%rbx,%rax,1)
movl   $0xa3e65,0x66(%rbx,%rax,1)
movl   $0x6572703c,0x63(%rbx,%rax,1)
65
lea    (%rbx,%rax,1),%rdi
add    $0x69,%rdi
mov    %r14,%rsi
call   1030 <sprintf@plt>
movslq %eax,%rcx
lea    (%rcx,%r15,1),%rax
add    $0x36,%rax
movups 0xe74(%rip),%xmm0
movups %xmm0,0x36(%rcx,%r15,1)
movups 0xe71(%rip),%xmm0
movups %xmm0,0x40(%rcx,%r15,1)
sub    %ebx,%eax
add    $0x19,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [22 x i8] c"<H1>Action Sent</H1>\0A\00"
@.str.1 = [31 x i8] c"<table border=1><tr><td><pre>\0A\00"
@.str.2 = [26 x i8] c"</pre></td></tr></table>\0A\00"
@.str.3 = [24 x i8] c"<H1>Action Result</H1>\0A\00"
@.str.4 = [7 x i8] c"<pre>\0A\00"
define i32 @do_action(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
%9 = load i8*, i8** %4
store i8* %9, i8** %8
%10 = load i8*, i8** %4
%11 = call i32 @sprintf(i8* %10, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%12 = load i8*, i8** %4
%13 = sext i32 %11 to i64
%14 = getelementptr inbounds i8, i8* %12, i64 %13
store i8* %14, i8** %4
%15 = load i8*, i8** %4
%16 = call i32 @sprintf(i8* %15, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%17 = load i8*, i8** %4
%18 = sext i32 %16 to i64
%19 = getelementptr inbounds i8, i8* %17, i64 %18
store i8* %19, i8** %4
%20 = load i8*, i8** %4
%21 = load i8*, i8** %5
%22 = call i32 @sprintf(i8* %20, i8* %21)
%23 = load i8*, i8** %4
%24 = sext i32 %22 to i64
%25 = getelementptr inbounds i8, i8* %23, i64 %24
store i8* %25, i8** %4
%26 = load i8*, i8** %4
%27 = call i32 @sprintf(i8* %26, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%28 = load i8*, i8** %4
%29 = sext i32 %27 to i64
%30 = getelementptr inbounds i8, i8* %28, i64 %29
store i8* %30, i8** %4
%31 = load i8*, i8** %4
%32 = call i32 @sprintf(i8* %31, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%33 = load i8*, i8** %4
%34 = sext i32 %32 to i64
%35 = getelementptr inbounds i8, i8* %33, i64 %34
store i8* %35, i8** %4
%36 = load i8*, i8** %4
%37 = call i32 @sprintf(i8* %36, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%38 = load i8*, i8** %4
%39 = sext i32 %37 to i64
%40 = getelementptr inbounds i8, i8* %38, i64 %39
store i8* %40, i8** %4
%41 = load i8*, i8** %4
%42 = load i8*, i8** %6
%43 = call i32 @sprintf(i8* %41, i8* %42)
%44 = load i8*, i8** %4
%45 = sext i32 %43 to i64
%46 = getelementptr inbounds i8, i8* %44, i64 %45
store i8* %46, i8** %4
%47 = load i8*, i8** %4
%48 = call i32 @sprintf(i8* %47, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%49 = load i8*, i8** %4
%50 = sext i32 %48 to i64
%51 = getelementptr inbounds i8, i8* %49, i64 %50
store i8* %51, i8** %4
%52 = load i8*, i8** %4
%53 = load i8*, i8** %8
%54 = ptrtoint i8* %52 to i64
%55 = ptrtoint i8* %53 to i64
%56 = sub i64 %54, %55
%57 = trunc i64 %56 to i32
store i32 %57, i32* %7
%58 = load i32, i32* %7
ret i32 %58
}

LLVM IR (-O2):
@.str = [22 x i8] c"<H1>Action Sent</H1>\0A\00"
@.str.1 = [31 x i8] c"<table border=1><tr><td><pre>\0A\00"
@.str.2 = [26 x i8] c"</pre></td></tr></table>\0A\00"
@.str.3 = [24 x i8] c"<H1>Action Result</H1>\0A\00"
@.str.4 = [7 x i8] c"<pre>\0A\00"
define i32 @do_action(i8* %0, i8* nocapture %1, i8* nocapture %2) {
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(22) %0, i8* align 1 dereferenceable(22) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i64 22, i1 false)
%4 = getelementptr inbounds i8, i8* %0, i64 21
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(31) %4, i8* align 1 dereferenceable(31) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i64 31, i1 false)
%5 = getelementptr inbounds i8, i8* %0, i64 51
%6 = tail call i32 @sprintf(i8* %5, i8* dereferenceable(1) %1)
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i8, i8* %5, i64 %7
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(26) %8, i8* align 1 dereferenceable(26) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i64 25, i1 false)
%9 = getelementptr inbounds i8, i8* %8, i64 25
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(24) %9, i8* align 1 dereferenceable(24) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i64 23, i1 false)
%10 = getelementptr inbounds i8, i8* %9, i64 23
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(7) %10, i8* align 1 dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i64 7, i1 false)
%11 = getelementptr inbounds i8, i8* %10, i64 6
%12 = tail call i32 @sprintf(i8* %11, i8* dereferenceable(1) %2)
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %11, i64 %13
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(26) %14, i8* align 1 dereferenceable(26) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i64 26, i1 false)
%15 = getelementptr inbounds i8, i8* %14, i64 25
%16 = ptrtoint i8* %15 to i64
%17 = ptrtoint i8* %0 to i64
%18 = sub i64 %16, %17
%19 = trunc i64 %18 to i32
ret i32 %19
}