#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 */
struct sms_message {
  int dummy;
};

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, char *);
int /*<<< orphan*/ stdout;
char *strsep(char **, char *);
int process_server_reply(long httpd_code, char *responce,
                         struct sms_message *msg) {
  char *cp;
  char *strp = responce;
  int line = 0;
  int msgid = -1;
  int status = -1;
  char *errmsg = NULL;
  int rc = -1;
  do {
  } while (0);
  while ((cp = strsep(&strp, "\n\r")) != NULL) {
    if (!*cp) {
      continue;
    }
    switch (line) {
    case 0:
      msgid = atoi(cp);
      break;
    case 1:
      status = atoi(cp);
      break;
    case 2:
      errmsg = cp;
      break;
    default:
      do {
      } while (0);
    }
    line++;
  }
  if (msgid > 0) {
    fprintf(stdout, "OK: %d (%s)\n", msgid, errmsg);
    rc = 0;
  } else {
    fprintf(stdout, "ERROR: %d (%s)\n", status, errmsg ?: "");
  }
  return rc;
}


x86 assembly (clang, -O0):
<process_server_reply>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0xffffffff,-0x30(%rbp)
movl   $0xffffffff,-0x34(%rbp)
movq   $0x0,-0x40(%rbp)
movl   $0xffffffff,-0x44(%rbp)
jmp    1175 <process_server_reply+0x45>
jmp    117a <process_server_reply+0x4a>
lea    -0x28(%rbp),%rdi
lea    0xe7b(%rip),%rsi
call   1040 <strsep@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     122b <process_server_reply+0xfb>
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
jne    11aa <process_server_reply+0x7a>
jmp    117a <process_server_reply+0x4a>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x48(%rbp)
test   %eax,%eax
je     11df <process_server_reply+0xaf>
jmp    11bd <process_server_reply+0x8d>
mov    -0x48(%rbp),%eax
sub    $0x1,%eax
je     11f0 <process_server_reply+0xc0>
jmp    11ce <process_server_reply+0x9e>
mov    -0x48(%rbp),%eax
sub    $0x2,%eax
je     1201 <process_server_reply+0xd1>
jmp    120e <process_server_reply+0xde>
mov    -0x20(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x30(%rbp)
jmp    121d <process_server_reply+0xed>
mov    -0x20(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x34(%rbp)
jmp    121d <process_server_reply+0xed>
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
jmp    121d <process_server_reply+0xed>
jmp    1213 <process_server_reply+0xe3>
jmp    1218 <process_server_reply+0xe8>
jmp    121d <process_server_reply+0xed>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    117a <process_server_reply+0x4a>
cmpl   $0x0,-0x30(%rbp)
jle    125d <process_server_reply+0x12d>
mov    0x2da4(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%edx
mov    -0x40(%rbp),%rcx
lea    0xdb7(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0x0,-0x44(%rbp)
jmp    12b4 <process_server_reply+0x184>
mov    0x2d7c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x58(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x50(%rbp)
cmp    $0x0,%rax
je     128e <process_server_reply+0x15e>
mov    -0x50(%rbp),%rax
mov    %rax,-0x60(%rbp)
jmp    129e <process_server_reply+0x16e>
lea    0xd7a(%rip),%rax
mov    %rax,-0x60(%rbp)
jmp    129e <process_server_reply+0x16e>
mov    -0x54(%rbp),%edx
mov    -0x58(%rbp),%edi
mov    -0x60(%rbp),%rcx
lea    0xd61(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x44(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process_server_reply>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,(%rsp)
mov    $0xffffffff,%r12d
xor    %r13d,%r13d
lea    0xeb1(%rip),%rbp
mov    %rsp,%rbx
mov    $0xffffffff,%r15d
xor    %r14d,%r14d
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1040 <strsep@plt>
test   %rax,%rax
je     11b1 <process_server_reply+0x81>
cmpb   $0x0,(%rax)
je     1160 <process_server_reply+0x30>
cmp    $0x2,%r13d
je     1197 <process_server_reply+0x67>
cmp    $0x1,%r13d
je     11a0 <process_server_reply+0x70>
test   %r13d,%r13d
jne    119a <process_server_reply+0x6a>
mov    %rax,%rdi
call   1050 <atoi@plt>
mov    %eax,%r12d
add    $0x1,%r13d
jmp    1160 <process_server_reply+0x30>
mov    %rax,%r14
add    $0x1,%r13d
jmp    1160 <process_server_reply+0x30>
mov    %rax,%rdi
call   1050 <atoi@plt>
mov    %eax,%r15d
add    $0x1,%r13d
jmp    1160 <process_server_reply+0x30>
mov    0x2e28(%rip),%rax
mov    (%rax),%edi
test   %r12d,%r12d
jle    11d5 <process_server_reply+0xa5>
lea    0xe3d(%rip),%rsi
mov    %r12d,%edx
mov    %r14,%rcx
call   1030 <fprintf@plt>
xor    %eax,%eax
jmp    11f7 <process_server_reply+0xc7>
test   %r14,%r14
lea    0xe30(%rip),%rcx
cmovne %r14,%rcx
lea    0xe26(%rip),%rsi
mov    %r15d,%edx
call   1030 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sms_message = type { i32 }
@.str = [3 x i8] c"\0A\0D\00"
@stdout = global i32 0
@.str.1 = [13 x i8] c"OK: %d (%s)\0A\00"
@.str.2 = [16 x i8] c"ERROR: %d (%s)\0A\00"
@.str.3 = [1 x i8] zeroinitializer
define i32 @process_server_reply(i64 %0, i8* %1, %struct.sms_message* %2) {
%4 = alloca i64
%5 = alloca i8*
%6 = alloca %struct.sms_message*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i32
store i64 %0, i64* %4
store i8* %1, i8** %5
store %struct.sms_message* %2, %struct.sms_message** %6
%14 = load i8*, i8** %5
store i8* %14, i8** %8
store i32 0, i32* %9
store i32 -1, i32* %10
store i32 -1, i32* %11
store i8* null, i8** %12
store i32 -1, i32* %13
br label %15
15: ; preds = %3
br label %16
16: ; preds = %15
br label %17
17: ; preds = %38, %24, %16
%18 = call i8* @strsep(i8** %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %18, i8** %7
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %41
20: ; preds = %17
%21 = load i8*, i8** %7
%22 = load i8, i8* %21
%23 = icmp ne i8 %22, 0
br i1 %23, label %25, label %24
24: ; preds = %20
br label %17
25: ; preds = %20
%26 = load i32, i32* %9
switch i32 %26, label %35 [
i32 0, label %27
i32 1, label %30
i32 2, label %33
]
27: ; preds = %25
%28 = load i8*, i8** %7
%29 = call i32 @atoi(i8* %28)
store i32 %29, i32* %10
br label %38
30: ; preds = %25
%31 = load i8*, i8** %7
%32 = call i32 @atoi(i8* %31)
store i32 %32, i32* %11
br label %38
33: ; preds = %25
%34 = load i8*, i8** %7
store i8* %34, i8** %12
br label %38
35: ; preds = %25
br label %36
36: ; preds = %35
br label %37
37: ; preds = %36
br label %38
38: ; preds = %37, %33, %30, %27
%39 = load i32, i32* %9
%40 = add nsw i32 %39, 1
store i32 %40, i32* %9
br label %17
41: ; preds = %17
%42 = load i32, i32* %10
%43 = icmp sgt i32 %42, 0
br i1 %43, label %44, label %49
44: ; preds = %41
%45 = load i32, i32* @stdout
%46 = load i32, i32* %10
%47 = load i8*, i8** %12
%48 = call i32 @fprintf(i32 %45, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %46, i8* %47)
store i32 0, i32* %13
br label %59
49: ; preds = %41
%50 = load i32, i32* @stdout
%51 = load i32, i32* %11
%52 = load i8*, i8** %12
%53 = icmp ne i8* %52, null
br i1 %53, label %54, label %55
54: ; preds = %49
br label %56
55: ; preds = %49
br label %56
56: ; preds = %55, %54
%57 = phi i8* [ %52, %54 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), %55 ]
%58 = call i32 @fprintf(i32 %50, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %51, i8* %57)
br label %59
59: ; preds = %56, %44
%60 = load i32, i32* %13
ret i32 %60
}

LLVM IR (-O2):
%struct.sms_message = type { i32 }
@.str = [3 x i8] c"\0A\0D\00"
@stdout = global i32 0
@.str.1 = [13 x i8] c"OK: %d (%s)\0A\00"
@.str.2 = [16 x i8] c"ERROR: %d (%s)\0A\00"
@.str.3 = [1 x i8] zeroinitializer
define i32 @process_server_reply(i64 %0, i8* %1, %struct.sms_message* nocapture readnone %2) {
%4 = alloca i8*
%5 = bitcast i8** %4 to i8*
store i8* %1, i8** %4
br label %6
6: ; preds = %23, %3
%7 = phi i32 [ %27, %23 ], [ 0, %3 ]
%8 = phi i32 [ %24, %23 ], [ -1, %3 ]
%9 = phi i32 [ %25, %23 ], [ -1, %3 ]
%10 = phi i8* [ %26, %23 ], [ null, %3 ]
br label %11
11: ; preds = %6, %14
%12 = call i8* @strsep(i8** %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i8* %12, null
br i1 %13, label %28, label %14
14: ; preds = %11
%15 = load i8, i8* %12
%16 = icmp eq i8 %15, 0
br i1 %16, label %11, label %17
17: ; preds = %14
switch i32 %7, label %23 [
i32 0, label %18
i32 1, label %20
i32 2, label %22
]
18: ; preds = %17
%19 = call i32 @atoi(i8* %12)
br label %23
20: ; preds = %17
%21 = call i32 @atoi(i8* %12)
br label %23
22: ; preds = %17
br label %23
23: ; preds = %17, %22, %20, %18
%24 = phi i32 [ %8, %17 ], [ %8, %22 ], [ %8, %20 ], [ %19, %18 ]
%25 = phi i32 [ %9, %17 ], [ %9, %22 ], [ %21, %20 ], [ %9, %18 ]
%26 = phi i8* [ %10, %17 ], [ %12, %22 ], [ %10, %20 ], [ %10, %18 ]
%27 = add nuw nsw i32 %7, 1
br label %6
28: ; preds = %11
%29 = icmp sgt i32 %8, 0
%30 = load i32, i32* @stdout
br i1 %29, label %31, label %33
31: ; preds = %28
%32 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %8, i8* %10)
br label %37
33: ; preds = %28
%34 = icmp eq i8* %10, null
%35 = select i1 %34, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i8* %10
%36 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %9, i8* %35)
br label %37
37: ; preds = %33, %31
%38 = phi i32 [ 0, %31 ], [ -1, %33 ]
ret i32 %38
}