#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 int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ print(int *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sm4_decrypt(int *, int *);
int /*<<< orphan*/ sm4_encrypt(int *, int *);
int main(int argc, const char *argv[]) {
  uint32_t buffer[4] = {0x01234567, 0x89abcdef, 0xfedcba98, 0x76543210};
  uint32_t key[4] = {0x01234567, 0x89abcdef, 0xfedcba98, 0x76543210};
  printf("the plaintext:\t");
  print(buffer, 4);
  printf("the key:\t");
  print(key, 4);
  sm4_encrypt(buffer, key);
  printf("the ciphertext:\t");
  print(buffer, 4);
  sm4_decrypt(buffer, key);
  printf("the plaintext:\t");
  print(buffer, 4);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xe93(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe90(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xe7d(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xe7a(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xe77(%rip),%rdi
call   1030 <printf@plt>
lea    -0x20(%rbp),%rdi
mov    $0x4,%esi
call   1040 <print@plt>
lea    0xe6d(%rip),%rdi
call   1030 <printf@plt>
lea    -0x30(%rbp),%rdi
mov    $0x4,%esi
call   1040 <print@plt>
lea    -0x20(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1050 <sm4_encrypt@plt>
lea    0xe50(%rip),%rdi
call   1030 <printf@plt>
lea    -0x20(%rbp),%rdi
mov    $0x4,%esi
call   1040 <print@plt>
lea    -0x20(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1060 <sm4_decrypt@plt>
lea    0xe0f(%rip),%rdi
call   1030 <printf@plt>
lea    -0x20(%rbp),%rdi
mov    $0x4,%esi
call   1040 <print@plt>
mov    0x2dc5(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
movaps 0xea0(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
lea    0xea0(%rip),%r14
mov    %r14,%rdi
call   1030 <printf@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x4,%esi
call   1040 <print@plt>
lea    0xe8f(%rip),%rdi
call   1030 <printf@plt>
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0x4,%esi
call   1040 <print@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <sm4_encrypt@plt>
lea    0xe72(%rip),%rdi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
call   1040 <print@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <sm4_decrypt@plt>
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
call   1040 <print@plt>
mov    0x2def(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@__const.main.buffer = [4 x i32] [i32 19088743, i32 -1985229329, i32 -19088744, i32 1985229328]
@__const.main.key = [4 x i32] [i32 19088743, i32 -1985229329, i32 -19088744, i32 1985229328]
@.str = [16 x i8] c"the plaintext:\09\00"
@.str.1 = [10 x i8] c"the key:\09\00"
@.str.2 = [17 x i8] c"the ciphertext:\09\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [4 x i32]
%7 = alloca [4 x i32]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = bitcast [4 x i32]* %6 to i8*
%9 = bitcast [4 x i32]* %7 to i8*
%10 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%11 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 0
%12 = call i32 @print(i32* %11, i32 4)
%13 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%14 = getelementptr inbounds [4 x i32], [4 x i32]* %7, i64 0, i64 0
%15 = call i32 @print(i32* %14, i32 4)
%16 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 0
%17 = getelementptr inbounds [4 x i32], [4 x i32]* %7, i64 0, i64 0
%18 = call i32 @sm4_encrypt(i32* %16, i32* %17)
%19 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%20 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 0
%21 = call i32 @print(i32* %20, i32 4)
%22 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 0
%23 = getelementptr inbounds [4 x i32], [4 x i32]* %7, i64 0, i64 0
%24 = call i32 @sm4_decrypt(i32* %22, i32* %23)
%25 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%26 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 0
%27 = call i32 @print(i32* %26, i32 4)
%28 = load i32, i32* @EXIT_SUCCESS
%29 = call i32 @exit(i32 %28)
unreachable
}

LLVM IR (-O2):
@__const.main.key = [4 x i32] [i32 19088743, i32 -1985229329, i32 -19088744, i32 1985229328]
@.str = [16 x i8] c"the plaintext:\09\00"
@.str.1 = [10 x i8] c"the key:\09\00"
@.str.2 = [17 x i8] c"the ciphertext:\09\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [4 x i32]
%4 = alloca [4 x i32]
%5 = bitcast [4 x i32]* %3 to i8*
%6 = bitcast [4 x i32]* %4 to i8*
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 0
%9 = call i32 @print(i32* %8, i32 4)
%10 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%11 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 0
%12 = call i32 @print(i32* %11, i32 4)
%13 = call i32 @sm4_encrypt(i32* %8, i32* %11)
%14 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @print(i32* %8, i32 4)
%16 = call i32 @sm4_decrypt(i32* %8, i32* %11)
%17 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%18 = call i32 @print(i32* %8, i32 4)
%19 = load i32, i32* @EXIT_SUCCESS
%20 = call i32 @exit(i32 %19)
unreachable
}