#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 coder {
  int dummy;
};

/* Variables and functions */
int write_stop_bit_code(struct coder *, int, int const, unsigned char **);
int pack_stopbits_item(struct coder *coder_inst, const int item,
                       unsigned char **output, const int coding_parameter) {
  int s = 0;
  if (item > 0)
    s = 1 + (item - 1) * 2;
  else if (item < 0)
    s = 2 + (-item - 1) * 2;
  return write_stop_bit_code(coder_inst, s, coding_parameter, output);
}


x86 assembly (clang, -O0):
<pack_stopbits_item>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    114b <pack_stopbits_item+0x3b>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
shl    $0x1,%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    116b <pack_stopbits_item+0x5b>
cmpl   $0x0,-0xc(%rbp)
jge    1166 <pack_stopbits_item+0x56>
xor    %eax,%eax
sub    -0xc(%rbp),%eax
sub    $0x1,%eax
shl    $0x1,%eax
add    $0x2,%eax
mov    %eax,-0x20(%rbp)
jmp    116b <pack_stopbits_item+0x5b>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%rcx
call   1030 <write_stop_bit_code@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pack_stopbits_item>:
mov    %ecx,%eax
mov    %rdx,%rcx
test   %esi,%esi
jle    1121 <pack_stopbits_item+0x11>
lea    (%rsi,%rsi,1),%edx
add    $0xffffffff,%edx
jmp    112f <pack_stopbits_item+0x1f>
xor    %edx,%edx
test   %esi,%esi
jns    112f <pack_stopbits_item+0x1f>
not    %esi
lea    (%rsi,%rsi,1),%edx
add    $0x2,%edx
mov    %edx,%esi
mov    %eax,%edx
jmp    1030 <write_stop_bit_code@plt>

LLVM IR (-O0):
%struct.coder = type { i32 }
define i32 @pack_stopbits_item(%struct.coder* %0, i32 %1, i8** %2, i32 %3) {
%5 = alloca %struct.coder*
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i32
%9 = alloca i32
store %struct.coder* %0, %struct.coder** %5
store i32 %1, i32* %6
store i8** %2, i8*** %7
store i32 %3, i32* %8
store i32 0, i32* %9
%10 = load i32, i32* %6
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %4
%13 = load i32, i32* %6
%14 = sub nsw i32 %13, 1
%15 = mul nsw i32 %14, 2
%16 = add nsw i32 1, %15
store i32 %16, i32* %9
br label %27
17: ; preds = %4
%18 = load i32, i32* %6
%19 = icmp slt i32 %18, 0
br i1 %19, label %20, label %26
20: ; preds = %17
%21 = load i32, i32* %6
%22 = sub nsw i32 0, %21
%23 = sub nsw i32 %22, 1
%24 = mul nsw i32 %23, 2
%25 = add nsw i32 2, %24
store i32 %25, i32* %9
br label %26
26: ; preds = %20, %17
br label %27
27: ; preds = %26, %12
%28 = load %struct.coder*, %struct.coder** %5
%29 = load i32, i32* %9
%30 = load i32, i32* %8
%31 = load i8**, i8*** %7
%32 = call i32 @write_stop_bit_code(%struct.coder* %28, i32 %29, i32 %30, i8** %31)
ret i32 %32
}

LLVM IR (-O2):
%struct.coder = type { i32 }
define i32 @pack_stopbits_item(%struct.coder* %0, i32 %1, i8** %2, i32 %3) {
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %9
6: ; preds = %4
%7 = shl nuw i32 %1, 1
%8 = add i32 %7, -1
br label %15
9: ; preds = %4
%10 = icmp slt i32 %1, 0
br i1 %10, label %11, label %15
11: ; preds = %9
%12 = xor i32 %1, -1
%13 = shl nsw i32 %12, 1
%14 = add nsw i32 %13, 2
br label %15
15: ; preds = %9, %11, %6
%16 = phi i32 [ %8, %6 ], [ %14, %11 ], [ 0, %9 ]
%17 = tail call i32 @write_stop_bit_code(%struct.coder* %0, i32 %16, i32 %3, i8** %2)
ret i32 %17
}