#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 */
typedef scalar_t__ uint32_t;
typedef int int8_t;
typedef int /*<<< orphan*/ int32_t;

/* Variables and functions */
scalar_t__ *add_cigar(scalar_t__ *, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                      scalar_t__, char);
uint32_t *store_previous_m(int8_t choice, uint32_t *length_m,
                           uint32_t *length_x, int32_t *p, int32_t *s,
                           uint32_t *new_cigar) {
  if ((*length_m) && (choice == 2 || !choice)) {
    new_cigar = add_cigar(new_cigar, p, s, (*length_m), '=');
    (*length_m) = 0;
  } else if ((*length_x) && (choice == 1 || !choice)) {
    new_cigar = add_cigar(new_cigar, p, s, (*length_x), 'X');
    (*length_x) = 0;
  }
  return new_cigar;
}


x86 assembly (clang, -O0):
<store_previous_m>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     1183 <store_previous_m+0x73>
cmpl   $0x2,-0x4(%rbp)
je     1151 <store_previous_m+0x41>
cmpl   $0x0,-0x4(%rbp)
jne    1183 <store_previous_m+0x73>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
mov    $0x3d,%r8d
call   1030 <add_cigar@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movq   $0x0,(%rax)
jmp    11d7 <store_previous_m+0xc7>
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
je     11d2 <store_previous_m+0xc2>
cmpl   $0x1,-0x4(%rbp)
je     11a5 <store_previous_m+0x95>
cmpl   $0x0,-0x4(%rbp)
jne    11d2 <store_previous_m+0xc2>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x18(%rbp),%rax
mov    (%rax),%rcx
mov    $0x58,%r8d
call   1030 <add_cigar@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
jmp    11d7 <store_previous_m+0xc7>
mov    -0x30(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<store_previous_m>:
push   %r15
push   %r14
push   %rbx
mov    %r9,%rax
mov    %rdx,%r14
test   $0xfffffffd,%edi
jne    1147 <store_previous_m+0x37>
mov    %rsi,%r15
mov    (%rsi),%rbx
test   %rbx,%rbx
je     1147 <store_previous_m+0x37>
mov    %rax,%rdi
mov    %rcx,%rsi
mov    %r8,%rdx
mov    %rbx,%rcx
mov    $0x3d,%r8d
call   1030 <add_cigar@plt>
jmp    116e <store_previous_m+0x5e>
cmp    $0x1,%edi
ja     1175 <store_previous_m+0x65>
mov    (%r14),%rbx
test   %rbx,%rbx
je     1175 <store_previous_m+0x65>
mov    %rax,%rdi
mov    %rcx,%rsi
mov    %r8,%rdx
mov    %rbx,%rcx
mov    $0x58,%r8d
call   1030 <add_cigar@plt>
mov    %r14,%r15
movq   $0x0,(%r15)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64* @store_previous_m(i32 %0, i64* %1, i64* %2, i32* %3, i32* %4, i64* %5) {
%7 = alloca i32
%8 = alloca i64*
%9 = alloca i64*
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i64*
store i32 %0, i32* %7
store i64* %1, i64** %8
store i64* %2, i64** %9
store i32* %3, i32** %10
store i32* %4, i32** %11
store i64* %5, i64** %12
%13 = load i64*, i64** %8
%14 = load i64, i64* %13
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %30
16: ; preds = %6
%17 = load i32, i32* %7
%18 = icmp eq i32 %17, 2
br i1 %18, label %22, label %19
19: ; preds = %16
%20 = load i32, i32* %7
%21 = icmp ne i32 %20, 0
br i1 %21, label %30, label %22
22: ; preds = %19, %16
%23 = load i64*, i64** %12
%24 = load i32*, i32** %10
%25 = load i32*, i32** %11
%26 = load i64*, i64** %8
%27 = load i64, i64* %26
%28 = call i64* @add_cigar(i64* %23, i32* %24, i32* %25, i64 %27, i8 signext 61)
store i64* %28, i64** %12
%29 = load i64*, i64** %8
store i64 0, i64* %29
br label %49
30: ; preds = %19, %6
%31 = load i64*, i64** %9
%32 = load i64, i64* %31
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %48
34: ; preds = %30
%35 = load i32, i32* %7
%36 = icmp eq i32 %35, 1
br i1 %36, label %40, label %37
37: ; preds = %34
%38 = load i32, i32* %7
%39 = icmp ne i32 %38, 0
br i1 %39, label %48, label %40
40: ; preds = %37, %34
%41 = load i64*, i64** %12
%42 = load i32*, i32** %10
%43 = load i32*, i32** %11
%44 = load i64*, i64** %9
%45 = load i64, i64* %44
%46 = call i64* @add_cigar(i64* %41, i32* %42, i32* %43, i64 %45, i8 signext 88)
store i64* %46, i64** %12
%47 = load i64*, i64** %9
store i64 0, i64* %47
br label %48
48: ; preds = %40, %37, %30
br label %49
49: ; preds = %48, %22
%50 = load i64*, i64** %12
ret i64* %50
}

LLVM IR (-O2):
define i64* @store_previous_m(i32 %0, i64* nocapture %1, i64* nocapture %2, i32* %3, i32* %4, i64* %5) {
%7 = load i64, i64* %1
%8 = icmp ne i64 %7, 0
%9 = and i32 %0, -3
%10 = icmp eq i32 %9, 0
%11 = and i1 %10, %8
br i1 %11, label %12, label %14
12: ; preds = %6
%13 = tail call i64* @add_cigar(i64* %5, i32* %3, i32* %4, i64 %7, i8 signext 61)
br label %21
14: ; preds = %6
%15 = load i64, i64* %2
%16 = icmp ne i64 %15, 0
%17 = icmp ult i32 %0, 2
%18 = and i1 %17, %16
br i1 %18, label %19, label %24
19: ; preds = %14
%20 = tail call i64* @add_cigar(i64* %5, i32* %3, i32* %4, i64 %15, i8 signext 88)
br label %21
21: ; preds = %12, %19
%22 = phi i64* [ %2, %19 ], [ %1, %12 ]
%23 = phi i64* [ %20, %19 ], [ %13, %12 ]
store i64 0, i64* %22
br label %24
24: ; preds = %21, %14
%25 = phi i64* [ %5, %14 ], [ %23, %21 ]
ret i64* %25
}