#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*/ printf(char *, int, char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
void print_errmess(unsigned char *raw_msg) {
  int errcode, i;
  char message[(4096 - 1 - 4 - 1)];
  errcode = 0;
  for (i = 0; i < 4; i++) {
    errcode += (raw_msg[1 + i] << (8 * i));
  }
  strncpy(message, (char *)raw_msg + 5, (4096 - 1 - 4 - 1));
  message[(4096 - 1 - 4 - 1) - 1] = '\0';
  printf("Error 0x%x, server said: %s\n", errcode, message);
}


x86 assembly (clang, -O0):
<print_errmess>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1010,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x4,-0x10(%rbp)
jge    1174 <print_errmess+0x54>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
mov    -0x10(%rbp),%ecx
shl    $0x3,%ecx
shl    %cl,%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113d <print_errmess+0x1d>
lea    -0x1010(%rbp),%rdi
mov    -0x8(%rbp),%rsi
add    $0x5,%rsi
mov    $0xffa,%edx
call   1030 <strncpy@plt>
movb   $0x0,-0x17(%rbp)
mov    -0xc(%rbp),%esi
lea    -0x1010(%rbp),%rdx
lea    0xe5e(%rip),%rdi
call   1040 <printf@plt>
add    $0x1010,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_errmess>:
push   %r14
push   %rbx
sub    $0x1008,%rsp
mov    0x1(%rdi),%ebx
lea    0x5(%rdi),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0xffa,%edx
call   1030 <strncpy@plt>
movb   $0x0,0xff9(%rsp)
lea    0xeb0(%rip),%rdi
mov    %ebx,%esi
mov    %r14,%rdx
call   1040 <printf@plt>
add    $0x1008,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [29 x i8] c"Error 0x%x, server said: %s\0A\00"
define void @print_errmess(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca [4090 x i8]
store i8* %0, i8** %2
store i32 0, i32* %3
store i32 0, i32* %4
br label %6
6: ; preds = %22, %1
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 4
br i1 %8, label %9, label %25
9: ; preds = %6
%10 = load i8*, i8** %2
%11 = load i32, i32* %4
%12 = add nsw i32 1, %11
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %10, i64 %13
%15 = load i8, i8* %14
%16 = zext i8 %15 to i32
%17 = load i32, i32* %4
%18 = mul nsw i32 8, %17
%19 = shl i32 %16, %18
%20 = load i32, i32* %3
%21 = add nsw i32 %20, %19
store i32 %21, i32* %3
br label %22
22: ; preds = %9
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 1
store i32 %24, i32* %4
br label %6
25: ; preds = %6
%26 = getelementptr inbounds [4090 x i8], [4090 x i8]* %5, i64 0, i64 0
%27 = load i8*, i8** %2
%28 = getelementptr inbounds i8, i8* %27, i64 5
%29 = call i32 @strncpy(i8* %26, i8* %28, i32 4090)
%30 = getelementptr inbounds [4090 x i8], [4090 x i8]* %5, i64 0, i64 4089
store i8 0, i8* %30
%31 = load i32, i32* %3
%32 = getelementptr inbounds [4090 x i8], [4090 x i8]* %5, i64 0, i64 0
%33 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %31, i8* %32)
ret void
}

LLVM IR (-O2):
@.str = [29 x i8] c"Error 0x%x, server said: %s\0A\00"
define void @print_errmess(i8* %0) {
%2 = alloca [4090 x i8]
%3 = getelementptr inbounds [4090 x i8], [4090 x i8]* %2, i64 0, i64 0
%4 = getelementptr inbounds i8, i8* %0, i64 1
%5 = load i8, i8* %4
%6 = zext i8 %5 to i32
%7 = getelementptr inbounds i8, i8* %0, i64 2
%8 = load i8, i8* %7
%9 = zext i8 %8 to i32
%10 = shl nuw nsw i32 %9, 8
%11 = or i32 %10, %6
%12 = getelementptr inbounds i8, i8* %0, i64 3
%13 = load i8, i8* %12
%14 = zext i8 %13 to i32
%15 = shl nuw nsw i32 %14, 16
%16 = or i32 %15, %11
%17 = getelementptr inbounds i8, i8* %0, i64 4
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = shl nuw i32 %19, 24
%21 = or i32 %20, %16
%22 = getelementptr inbounds i8, i8* %0, i64 5
%23 = call i32 @strncpy(i8* %3, i8* %22, i32 4090)
%24 = getelementptr inbounds [4090 x i8], [4090 x i8]* %2, i64 0, i64 4089
store i8 0, i8* %24
%25 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %21, i8* %3)
ret void
}